Get selected webgrid row

rated by 0 users
This post has 1 Reply | 3 Followers

Not Ranked
Points 20
subhankc Posted: 10-03-2008 3:40 PM

I have a webgrid which gets data from a sqldatasource. On click of a button, I want to get the value of the cells in the selected row and do some processing with the values. Any example in C# would be very helpful.

Thanks,

Subhankar.

Subhankar Choudhury
  • | Post Points: 20
Top 200 Contributor
Points 1,936
Infragistics Employee

One thing to keep in mind is that the UltraWebGrid can have multiple selected rows but only one ActiveRow. You can set the row selection to single in the designer or in the grid's InitializeLayout event like this:

e.Layout.SelectTypeRowDefault = SelectType.Single;

When you handle the button's click event, you can then select the cell collection off of the grid's selected row. Remember that SelectedRows is a collection and uses an integer indexer:

var myVal = myGrid.DisplayLayout.SelectedRows[0].Cells.FromKey("ColumnName").Value;

Using the ActiveRow works much the same way:

var myVal = myGrid.DisplayLayout.ActiveRow.Cells.FromKey("ColumnName").Value;

 Hope that helps.

-Aaron

Sincerely,
Aaron Marisi
Product Guidance Web Team Lead
Infragistics, Inc.

  • | Post Points: 5
Page 1 of 1 (2 items) | RSS