Click here to Skip to main content
12,830,888 members (47,920 online)

Check box within grid view is not selectable

GDdixit asked:

Open original thread
My code is as below and my problem is that when I used this code in Visual Studio
2008 it will not work properly. (I used this in my office, but not working)
Actually problem is that when I try to select the check box it cannot be selected.
Auto post back is true.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            BackColor="White" BorderColor="#CC9966" BorderWidth="1px" 
            CellPadding="4" DataKeyNames="Eid,Fname" 
            onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating" 
            onselectedindexchanged="GridView1_SelectedIndexChanged" ShowFooter="True" 
            style="z-index: 1; left: 126px; top: 262px; position: absolute; height: 140px; width: 448px" 
            onrowcommand="GridView1_RowCommand" AllowSorting="True" 
            onpageindexchanging="GridView1_PageIndexChanging" onsorting="GridView1_Sorting" 
            PageSize="2" AllowPaging="True" BorderStyle="None">
            <pagersettings firstpagetext="First" lastpagetext="Last" nextpagetext="Next">
                PreviousPageText="Prev" />

My cs file code is:
protected void showtxtbox(object sender, EventArgs e)
        CheckBox cb = (CheckBox)sender;
        GridViewRow gvr=(GridViewRow) cb.NamingContainer;
        int rrowindex = gvr.RowIndex;
        CheckBox cbb = (CheckBox)GridView1.Rows[rrowindex].Cells[6].Controls[1];
        TextBox txt=(TextBox)GridView1.Rows[rrowindex].Cells[6].Controls[2];
            if (cbb.Checked)
                txt.Visible = true;
            if (cbb.Checked == false)
                txt.Visible = false;


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy | Mobile
Web02 | 2.8.170326.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100