Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have very simple code in which I just want to check user have selected the record in grid or not for this what I have done is

public void chkSelect_CheckedChanged(object sender, EventArgs e)
{

CheckBox cbChkAllocate = (CheckBox)sender;
GridDataItem dataItem = (GridDataItem)cbChkAllocate.NamingContainer;

if (cbChkAllocate.Checked == true)
{
dtRoom = getDataTable();
dtRoom.Rows[dataItem.ItemIndex]["Transtatus"] = cbChkAllocate.Checked;

gwRoom.DataSource = dtRoom;
gwRoom.DataBind();
ViewState["dtRoom"] = dtRoom;

}
}

and In my aspx file I have placed this for check box

XML
<telerik:GridTemplateColumn  DataField="AllocationFlag" UniqueName="AllocationFlag" SortExpression="trans_status" >


                                            <ItemTemplate>
                                                <asp:CheckBox class="checkbox" ID="chkAllocate" runat="server"   OnCheckedChanged="chkSelect_CheckedChanged" AutoPostBack="true" />
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>


this event of checkbox selecteing gets fired every time which is ok and my datatable gets its value but after selecting more than many records and pressing submit button I am unable to get value from ViewState["dtRoom"] which gets null I have noting in my page load event
Posted
Comments
ZurdoDev 13-May-14 21:22pm    
Is there a reason you are using the ViewState directly? Use session instead.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900