i am getting nothing , i am trying to retrieve checkbox value and email address from gridview via code, I am succeeded in getting Checkbox value successfully but cannt get email address, even grid view has it, but i cant get, just blank, here is the code:

.cs :

protected void GridViewAdminViewEmplys_RowCommand(Object sender, GridViewCommandEventArgs e)
        if (e.CommandName == "Update")
            GridView gvr = GridViewAdminViewEmplys;
            int index = Convert.ToInt32(e.CommandArgument);
            int pk = Convert.ToInt32(GridViewAdminViewEmplys.DataKeys[index].Value);

            bool isChecked = (gvr.Rows[index].Cells[8].Controls[0] as CheckBox).Checked;
            //CheckBox chk = (CheckBox)gvr.Rows[index].FindControl("chkBoxStatus");
           // Response.Write(isChecked);
            if (isChecked == true)
                String email = gvr.Rows[index].Cells[3].Text;
                Response.Write("TRUE CONDITION");

                Response.Write("False condition");


<asp:GridView ID="GridViewAdminViewEmplys" runat="server" AllowPaging="True"
         AutoGenerateColumns="False" DataKeyNames="userid"
         DataSourceID="SqlDataSource1" AllowSorting="True" 
         OnRowCommand="GridViewAdminViewEmplys_RowCommand"  >
             <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
             <asp:HyperLinkField DataNavigateUrlFields="userid" 
                 DataTextField="userid" DataTextFormatString="{0}" HeaderText="Userid" 
                 InsertVisible="False" NavigateUrl="~/adminViewEmplyrFurther.aspx" 
                 SortExpression="userid" />
             <asp:BoundField DataField="fullname" HeaderText="fullname" 
                 SortExpression="fullname" />
             <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" />
             <asp:BoundField DataField="question" HeaderText="question" 
                 SortExpression="question" />
             <asp:BoundField DataField="answers" HeaderText="answers" 
                 SortExpression="answers" />
             <asp:BoundField DataField="doc" HeaderText="doc" SortExpression="doc" />
             <asp:BoundField DataField="roleid" HeaderText="roleid" 
                 SortExpression="roleid" />
             <asp:CheckBoxField DataField="active" HeaderText="Status" 
                 SortExpression="active" ReadOnly="false" />
             <%--<asp:TemplateField HeaderText="Status" >
                <asp:CheckBox ID="chkBoxStatus" runat="server" Checked='<%# Convert.ToString(Eval("active")) %>' />


help !!!

Recommended Answers

All 3 Replies

hi friend ,

guess your itemtemplate doesnt contain any property for email , it does has only for the checkbox which you have retrieved using find control in code behind.

hope this helps...

I can try to reproduce this in vb and get back to you. Hopefully someone else has insight.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.