Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does anyone know how to access the value of a Boolean which is displayed within a gridview as a checkbox?? The standard Grid view will render a bit type (i.e. Boolean) datatype into an ASP:CheckBoxField, but how can i access the value of the underlying data, either true/false.
Posted

Hi,
I have done the similar thing in windows app Gridview's click event,i want to access grid's selected row's 9th cell value which is a check box,try this and make your logic :)

C#
string valuechk = dataGridView1.CurrentRow.Cells[9].Value.ToString ();
// int value = int.Parse(valuechk);
 bool chkvalue = Convert.ToBoolean(valuechk);

 //if (dataGridView1.CurrentRow.Cells[8].Value == "0")
 if(chkvalue ==false)
      assignchk.Checked = false;//assignchk is a check box on form
  else
      assignchk.Checked = true;
 
Share this answer
 
Comments
advancedansh 11-Jul-11 6:17am    
hi,
sry this not what i m looking for.
thanks
Hi,

Try this if could fit to your needs, and could help...

In your client code:
<asp:TemplateField HeaderText="Delete">
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>


In your Code behind (example):
protected void btnDelete_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < grdDeleteTransaction.Rows.Count; i++)
        {
            var row = grdDeleteTransaction.Rows[i];
            var isTag = row.FindControl("CheckBox1");
            CheckBox checkbox = (CheckBox)isTag;
            if (checkbox.Checked)
            {
                // Do something here...               
            }
            else
            {
               // Do something here...  
            }
        }
        //.. 
    }



Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Regards,

Algem
 
Share this answer
 
Comments
advancedansh 11-Jul-11 6:22am    
is this code would help me in window application
Al Moje 11-Jul-11 22:30pm    
Sorry, I thought that you are developing under web application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900