Hi,
In server side code I have tried to retrieve the index of the select row but always get a null reference error on the statement to get the index. Here is the code that I have been tryying (with debut ptint statements to try and find the problem.
When I look at the e.CurrentSelectedRows in Quick Watch it shows there is a count of 1.
protected void gridCompany_RowSelectionChanged(object sender, SelectedRowEventArgs e)
{
Int32 ri = 0;
if (e.CurrentSelectedRows != null)
if (e.CurrentSelectedRows[0] == null)
System.Diagnostics.Debug.Print("Current selected row[0] is null but count is {0}", e.CurrentSelectedRows.Count);
else
// never hit this
// if not checking for null, this raises null reference error
ri = e.CurrentSelectedRows[0].Index;
}
System.Diagnostics.Debug.Print("Active row index {0}", ri);
// this raises error
ri = gridCompany.Behaviors.Selection.SelectedRows[0].Index;
Guid companyGuid = Guid.Parse(gridCompany.Rows[ri].DataKey.ToString());
FillGridUsers(companyGuid);
Hi Georgi,
Casting the e.CurrentSelectedRows[0] to a ControlDataRecord worked like a champ.
Thanks - NormD.
Hi Norm,
Can you try this to retrieve the index of the selected row:
((Infragistics.Web.UI.GridControls.ControlDataRecord)(e.CurrentSelectedRows[0])).Index
This is in case that you have
<ig:Selection RowSelectType="Single" Enabled="true" >
<AutoPostBackFlags RowSelectionChanged="True" />
</ig:Selection>
I hope this helps.
For any further questions do not hesitate to contact me.
Sincerely,
Georgi Sashev
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
I may have stumbled onto this. If I saved the initial dataset for the grid to a cache location and then re-bind that cached dataset to the grid during the RowSelectionChanged() event, I can retrieve the value of the row index OK.
This seems like an unnecessary performance hit and resource requirement. What in the recommended method by Infragistics - using a server side event like this or using a client side event to get the data key from the row and pas it back to a server method. What I am doing in this particular page is synchronizing 2 different grids but their data sources are not "static" so there are constructed in cod (not in the page XML).
Thanks - NormD
One more piece of information.
When I put a breakpoint before the statement that is trying to get the index of the selected row and I look at the e.CurrentSelectedRows in Quick View I do see the value of the selected row index in "_idPairs[1].value" and the "Key" of _idPairs[1] is the index of the selected record on the page.
I have tried with with EnableDataViewState set to true and false and they both work the same way. In all cases the EnableViewState for the grid itself is true.