I have a ultrawebgrid and when a user clicks on the row I want another ultrawebgrid to have the same seleted row. Something like this...
Dim selectedRow As UltraGridRow = wg1.DisplayLayout.SelectedRows(0)wg2.DisplayLayout.ActiveRow = selectedRow
First, you're mixing the concepts of "selected rows" and "active rows" between the two grid. An active row either has input focus or contains the cell that has input focus; the grid either has either exactly zero or one active rows at a time. By comparison, if you turn on row selection, you may have zero, one, or many selected rows at a time, any or none of which may be the active row.
Second, you can't set the active row in one WebGrid to be a row that exists in another WebGrid. Even if the two contain the same data, each row object is independent of each other. Instead, get some information from the appropriate row in one of your grids that allows you to uniquely identify it; a primary key is useful if your data has it. Then, find the corresponding row in the other grid that matches your unique identification, and select or activate that row as desired.
Ok, all that aside...
This is what I came up with. The only problem is that the ActiveRow doesnt get the SelectedRow properties (I understand the diff between Active and selected. I'm trying to emulate an end-user click where the row is made Active and it gets the selected row properties (ie back color, fore color). If I uncomment to the lines that set my formatting then that row stays like that all the time, not just when it's selected.
Thanks.
Dim count, i As Integer count = wgWirelessServices.Rows.Count Dim srvID As UltraGridColumn = wgWirelessServices.Columns(0) For i = 0 To count - 1 Step i + 1 If wgWirelessServices.Rows(i).GetCellText(srvID) = Session("service_id").ToString Then wgWirelessServices.DisplayLayout.ActiveRow = wgWirelessServices.Rows(i) ' wgWirelessServices.Rows(i).Style.BackColor = Drawing.Color.Orange ' wgWirelessServices.Rows(i).Style.ForeColor = Drawing.Color.White GridView1.SelectedIndex = i End If Next