Hi,
I am using ultrawebgrid in my project and I've a Checkbox template column. Once the user selects checkboxes, I've code to identify all the rows selected and then read certain column values for those selected rows. Here is the code snippet of the same:
***
private void GetSelectedFunds(UltraWebGrid uwg) { Boolean boolGroupSelectedFound = false; reportingperiodownerships = new List<ReportingPeriodOwnership>(); string sFundNbr;
foreach (UltraGridRow oRow in uwg.Rows) { if (boolGroupSelectedFound) break; if (oRow.HasChildRows) { foreach (UltraGridRow row in oRow.Rows) { if (!row.Cells[3].Value.Equals(0))//look for the "select" checkbox fields { boolGroupSelectedFound = true; ReportingPeriodOwnership rpo = new ReportingPeriodOwnership(); rpo.InternalID = int.Parse(SelectedUserInternalIdHiddenField.Value.Trim()); rpo.ReportingPeriodID = (int)row.Cells[1].Value; sFundNbr = (string)row.Cells[5].Value; reportingperiodownerships.Add(rpo); } } } } }***
The grid is being grouped by a column (Role). The code works fine when the grid is not sorted. But, when the user sorts the grid, the column values that I am reading [ReportingPerioID and sFundNbr] are the ones that are actual values in the checkbox selected rows. Looks like the actual place holder of the rows is changing.
can anyone help me with this?
Thanks,
Kala
Hello VR,
sskala said:the column values that I am reading [ReportingPerioID and sFundNbr] are the ones that are actual values in the checkbox selected rows.
I guess you are using server-side sorting, so let suppose that server-side sorting is enabled and you select the first row then sort the gird and try to get the selected row by index the index will be different based on sorting criteria applied. This should be the correct behavior of the grid.
I am using client side sorting. Did you look at the code that I've given? The problem is that even though we get the row index. How to read the other column values based on that. I tried but looks like it's not working...can you just give me an idea for that? Did you get a chance to test any similar code?
Kala,
sskala said: How to read the other column values based on that.
May be I'm missing something so, as I am able to see from the code provided by you at the thread this is c# code only. The grid aspx code is not provided anyway. What I've tested
protected void Button1_Click(object sender, EventArgs e)
{
foreach (UltraGridRow row in UltraWebGrid1.Rows)
if ((string)row.Cells[1].Value=="false")
//Get the the value of the next cell
Label1.Text =
row.Cells.FromKey("Data").Value.ToString();
}
Even the index is changed by client-side sorting I am able to get the correct value form the next cell using FromKey("key"); method
The grid looks like this:
Kala, am I missing something?
Let me know if you have any questions with this matter.
Thanks.