Link to home
Start Free TrialLog in
Avatar of saloj
salojFlag for Canada

asked on

get the specific checkbox value when the button is clicked on gridview

Hi EE,
I have GridView which has 3 checkboxes column and one button column. some records have all checkboxes are checked, some are just one or two are checked according to the database's check record.
suppose if i just check on the one checkbox and hit the button from the first record then it gets other checkboxes value too on my following code.

How can I get only the same record's selected checkbox value which is hitted.

[.aspx]
<asp:CheckBox ID="CheckBox0" runat="server" title="All" Checked='<%# HasRecord(Convert.ToInt32(Eval("art_id")),0) %>' />
<asp:CheckBox ID="CheckBox1" runat="server" title="All" Checked='<%# HasRecord(Convert.ToInt32(Eval("art_id")),1) %>' />
.
.
<asp:CheckBox ID="CheckBox5" runat="server" title="All" Checked='<%# HasRecord(Convert.ToInt32(Eval("art_id")),5) %>' />

<asp:Button ID="Button1" runat="server" Text="View" CommandName="view" CommandArgument='<%# Eval("art_id")%>'

[.aspx.cs]
   protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "view") {
 foreach (GridViewRow row in GridView1.Rows)
                {
                    artid = e.CommandArgument.ToString();
                    CheckBox cb0 = (CheckBox)row.FindControl("checkBox0");
                    CheckBox cb1 = (CheckBox)row.FindControl("checkBox1");
                    CheckBox cb2 = (CheckBox)row.FindControl("checkBox2");
                    CheckBox cb3 = (CheckBox)row.FindControl("checkBox3");
                    CheckBox cb4 = (CheckBox)row.FindControl("checkBox4");
                    CheckBox cb5 = (CheckBox)row.FindControl("checkBox5");  
                 if (cb0.Checked)
                    {
                        displayID = "0";
                    }
                    if (cb1.Checked)
                    {
                        displayID = "1";
                    }              
..........
            }
}
Avatar of BuggyCoder
BuggyCoder
Flag of India image

ASKER CERTIFIED SOLUTION
Avatar of Swapnil
Swapnil
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial