Solved

checkbox in gridview not fired

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

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…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

17 Experts available now in Live!

Get 1:1 Help Now