Solved

checkbox in gridview not fired

Posted on 2014-04-24
2
724 Views
Last Modified: 2014-04-25
Hi Expert,

I am working on asp.net web form.
I designed a usercontrol. In the user control I added gridview.
I added checkbox in gridview. But the event chkOne_OnCheckedChanged is not fired after I clicked the checkbox.

Appreciated for your help!!

                    <asp:GridView ID="gvNewCust" runat="server" AutoGenerateColumns="false" DataKeyNames="HierarchyID" AllowPaging="true"
                        EnableViewState="false" HeaderStyle-CssClass="DQLabel" Width="771px" OnRowDataBound="gvNewCust_RowDataBound">
                        <AlternatingRowStyle BackColor="#CCCCCC" />
                        <Columns>
                             <asp:TemplateField HeaderText="Select">
                                <ItemTemplate>
                                     <asp:CheckBox ID="chkOne" Checked="false" runat="server"  OnCheckedChanged="chkOne_OnCheckedChanged"  AutoPostBack="true"/>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="HierarchyID" HeaderText="HierarchyID" SortExpression="HierarchyID" />
                            <asp:BoundField DataField="isDeleted" HeaderText="isDeleted" SortExpression="isDeleted" />
                            <asp:BoundField DataField="InsertTS" HeaderText="InsertTS" SortExpression="InsertTS" />
                            <asp:BoundField DataField="InsertUserID" HeaderText="InsertUserID" SortExpression="InsertUserID" />
                            <asp:BoundField DataField="HierarchyNo" HeaderText="HierarchyNo" SortExpression="HierarchyNo" />
                            <asp:BoundField DataField="HierarchyName" HeaderText="HierarchyName" SortExpression="HierarchyName" />
                            <asp:BoundField DataField="RootNodeID" HeaderText="RootNodeID" SortExpression="RootNodeID" />
                            <asp:BoundField DataField="IsDefault" HeaderText="IsDefault" SortExpression="IsDefault" />
                        </Columns>
                        <HeaderStyle CssClass="DQLabel" Font-Bold="True" Font-Size="Small" />
                       
                    </asp:GridView>




---------------------------------------------------------------------------------------
//the following is not fired

        protected void chkOne_OnCheckedChanged(object sender, EventArgs e)
        {
            CheckBox chk = (CheckBox)sender;
            GridViewRow row = (GridViewRow)chk.Parent.Parent;
        }
0
Comment
Question by:jssong2000
2 Comments
 
LVL 8

Accepted Solution

by:
deepu chandran earned 500 total points
ID: 40021881
Hi,

In your Grid change the EnableViewState="true"  it is "False" Curretly

<asp:GridView ID="gvNewCust" runat="server" AutoGenerateColumns="false" DataKeyNames="HierarchyID"
            AllowPaging="true" EnableViewState="true" HeaderStyle-CssClass="DQLabel" Width="771px"
            >

Thanks
Deepu
0
 

Author Closing Comment

by:jssong2000
ID: 40023279
It works. Thank you!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question