Hi! I'm trying to get a value of a cell out of a selected row when a button is pushed. I'm using
DataGrid1.Behaviors.Selection.SelectedRows.Item(0).GetValue(0).ToString
and it's saying I need to put in a gridrecord as a field, because an integer is a bad parameter. I understand how to do that if I was using a for each loop, and went through, for example
For
MsgBox(row.Items.GetValue(0).ToString())
Next
But I don't know how to do that for a single, selected row. Where should I go from here?
Hi all,
As garciama suggests, when handling the RowSelectionChanged event, the selected row(s) can be accessed through the event argument.
Please contact me if you have any questions.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://es.infragistics.com/support
HI,
I am using it this way in the RowSelectionChanged event and works for me, I hope this help you.
TCtrITEM_ID.Text = e.CurrentSelectedRows(0).DataItem(1).ToString
Thanks.
Hi testhandle,
Even when only one row is selected in the grid you need to specify the index of that selected row in SelectedRows as such:
VB:
WebDataGrid1.Behaviors.Selection.SelectedRows(0).Items(0).Value.ToString()
C#:
WebDataGrid1.Behaviors.Selection.SelectedRows[0].Items[0].Value.ToString()
You can find more information about the Selection behaviors of the WebDataGrid at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0/?page=WebDataGrid_Selection.html
Additionally, illustrative samples demonstrating the WebDataGrid selection features are available from in our samples collection:
http://samples.infragistics.com/aspnet/Samples/WebDataGrid/Editing-and-Selection/Selection-Behavior/Default.aspx?cn=data-grid&sid=79feac59-7267-47ea-9228-ab1ca9804c51
I hope this helps. Please contact me if you have any questions.