Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
920
e.CurrentSelectedRows[0].Index raises null error
posted

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);

}

Parents Reply Children
No Data