Hi again,
The datagrid will get a dataset. We can find out what record the user
double-clicks by the this.myDataGrid.CurrentCell.RowNumber property. But if
the user 'sorts' the datagrid, then this RowNumber property is no longer
valid - is that right? If so, how can this be tracked?
Thanks in advance...
Jack.
Scott M. - 28 Aug 2005 15:54 GMT
That's correct. The row index in the grid will not necessarily be the same
row index as in your DataSet. What you should do to find the DataSet index
that corresponds to the DataGrid index is:
Make sure that your DataSet stores primary key data for each row.
Make sure that this PK data is also used in your DataGrid (you don't have to
display it in the grid, but it should be stored in some hidden control at
the very least).
In your code, you can then "Find" the right row of the DataSet, based on the
PK of the row in the DataGrid like this:
(assume PartNumber is the PK field name and lblPartNum is a label in the
DataGrid that is bound to PartNumber)
Dim theRow As DataRow = ds.Tables(0).Select("PartNumber='" &
CType(e.Item.FindControl("lblPartNum"), Label).Text & "'")(0)
FindControl takes in only control names, not indexes and returns an array of
possible matching rows, so you have to specify which array element you want
at the end of the line: (0)
-Scott
> Hi again,
>
[quoted text clipped - 5 lines]
> Thanks in advance...
> Jack.