Solved

checkbox in gridview not fired

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now