Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Retrieve Data from the Grid
Message
General information
Forum:
ASP.NET
Category:
WebForms
Miscellaneous
Thread ID:
00807651
Message ID:
00807706
Views:
16
Hi Stephen,

You can use the BindingManager to get the current row:
BindingManagerBase bm = this.dataGrid1.BindingContext
[this.dataGrid1.DataSource, this.dataGrid1.DataMember]; 
DataRow dr = ((DataRowView)bm.Current).Row; 
>I have a table with the following fields:
>
>PKid int Primary Key
>SName varchar(10) Short Name
>Desc varchar(40) Description
>
>
>I bound this table to a grid but I set visible to false for the "PKid" column.
>
>How do I retrieve the value for "PKid" from the record selected? I am able to get the row index of the selected row and use the index to retrieve the value from the datatable. However, when I change the order of the grid by clicking on the column header, the record order of the datatable does not change so I end up with the wrong record.
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Reply
Map
View

Click here to load this message in the networking platform