datagrid dataset links

  • Thread starter Thread starter Andrius N
  • Start date Start date
A

Andrius N

I have a dataset with 5 fields, 4 displayed in datagrid .1 is hidden by this
method as I dont need to display it:

ds.Tables(0).Columns("id").ColumnMapping = MappingType.Hidden

(also is there any other/better way to hide a column or size it to 0
width??)

I want to retrieve this ID column value when a grid row is selected.
If I use:
ds = DataGrid1.DataSource
i=ds.Rows(DataGrid1.CurrentRowIndex).Item(0)

This gives me correct value of i UNLESS grid has been sorted, then is wrong.
How do I sync the two, or what is the best way of getting a field value from
a dataset where it is not displayed in the datagrid?
Should I have the field as a column?
Andrew N
 
Hi Andrius,

Answers inline
I have a dataset with 5 fields, 4 displayed in datagrid .1 is hidden by this
method as I dont need to display it:

ds.Tables(0).Columns("id").ColumnMapping = MappingType.Hidden

(also is there any other/better way to hide a column or size it to 0
width??)

Use datagridstyles (columnstyles)
http://msdn.microsoft.com/library/d...ml/vbtskformattingthedatagridatdesigntime.asp
I want to retrieve this ID column value when a grid row is selected.
If I use:
ds = DataGrid1.DataSource
i=ds.Rows(DataGrid1.CurrentRowIndex).Item(0)

This gives me correct value of i UNLESS grid has been sorted, then is wrong.
How do I sync the two, or what is the best way of getting a field value from
a dataset where it is not displayed in the datagrid?
Should I have the field as a column?

Use the dataview between it

http://msdn.microsoft.com/library/d...mWindowsFormsDataGridClassDataSourceTopic.asp

I hope this helps?

Copr
 
Back
Top