datagrid dataset links

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
 
C

Cor Ligthert

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
 

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