Hide Datagrid columns

S

Shane Story

I have a dataset with two tables.

I make data view of each table, connect the parent table to one data grid
and the child table to the other datagrid, with a row filter, that gets set
when a user clicks a row in the parent.

I have PK/FK in the tables to know what to display.

I want to hide the PK/FK columns in the U/I, but still use them.

I can't seem to find a way to do this.

Any help would be appreciated.

Thanks,

Shane
 
C

Chris

Shane said:
I have a dataset with two tables.

I make data view of each table, connect the parent table to one data grid
and the child table to the other datagrid, with a row filter, that gets set
when a user clicks a row in the parent.

I have PK/FK in the tables to know what to display.

I want to hide the PK/FK columns in the U/I, but still use them.

I can't seem to find a way to do this.

Any help would be appreciated.

Thanks,

Shane

You have to assign a DataGridTableStyle to the datagrid. Then when you
attach the DataSource only columns that have a DataGridColumnStyle will
be shown but you can still access the other column from the datasource.

Hope this helps.

Chris
 
M

Mythran

Shane Story said:
I have a dataset with two tables.

I make data view of each table, connect the parent table to one data grid
and the child table to the other datagrid, with a row filter, that gets
set
when a user clicks a row in the parent.

I have PK/FK in the tables to know what to display.

I want to hide the PK/FK columns in the U/I, but still use them.

I can't seem to find a way to do this.

Any help would be appreciated.

Thanks,

Shane

Is this ASP.Net or WinForms? Not sure how to do the equivalent in WinForms,
but in ASP.Net you would handle the DataGrid_DataItemBound event. Check to
see if e.Item.ItemType is the type you want to mess with, then convert
e.Item.DataItem.Row to your DataRow. That would give you all values for the
DataItem that was bound.

HTH,
Mythran
 
S

Shane Story

It is a Win forms app. I already have it doing this... just have problems
because I need to hide columns and the one I need to hide is the PK in the
parent that I need to use for hidden FK in the child.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top