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
125
e.CurrentSelectedRows[0].DataKey[0]
posted

When I try to reference the selected row's datakey (single row selection only), I get the following error:{"Object reference not set to an instance of an object."}.

When I put a break point on the following line of code I can drill down and see the store value in the datakey: Session["rec_ssn"] = e.CurrentSelectedRows[0].DataKey[0];

Here is my grid:

<ig:WebDataGrid ID="dgSearchGrid" DataKeyFields="ssn" runat="server" Height="400px" Width="100%" AutoGenerateColumns="False" OnPageIndexChanged="dgSearchGrid_PageIndexChanged" OnColumnResized="dgSearchGrid_ColumnResized" OnColumnSorted="dgSearchGrid_ColumnSorted" OnRowSelectionChanged="dgSearchGrid_RowSelectionChanged">
<Columns>
<ig:BoundDataField DataFieldName="ssn" Key="ssn" Width="6em" >
<Header Text="SSN">
</Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="lname" Key="lname" >
<Header Text="Last Name">
</Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="fname" Key="fname" >
<Header Text="First Name">
</Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="mname" Key="mname" >
<Header Text="MI">
</Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="unit" Key="unit" >
<Header Text="Unit">
</Header>
</ig:BoundDataField>
</Columns>
<Behaviors>
<ig:Paging Enabled="true" PageSize="10"></ig:Paging>
<ig:RowSelectors Enabled="true">
</ig:RowSelectors>
<ig:Selection CellClickAction="Row" RowSelectType="Single" CellSelectType="None">
</ig:Selection>
<ig:ColumnResizing>
</ig:ColumnResizing>
<ig:Sorting SortingMode="Multi">
</ig:Sorting>
<ig:Activation>
</ig:Activation>
</Behaviors>
</ig:WebDataGrid>

Please help!!!

Thanks,

Lonnie

  • 15320
    Offline posted

    Hello Lonnie,

    Have you been able to resolve the issue?

    If you have any questions, please feel free to contact me.

    Sincerely,

    Tsanna

  • 15320
    Offline posted

    Hello Lonnie,

    Thank you for posting in our community.

    I've tested similar scenario and was unable to reproduce this exception.

    Could you please send me an isolated sample that demonstrates this behavior in order to test it on my side?

    Looking forward to your response.

    Sincerely,

    Tsanna