Solved

checkbox in gridview not fired

Posted on 2014-04-24
2
709 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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