Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
foreach (GridViewRow rowItem in GridView1.Rows)
{
CheckBox chk = (CheckBox)(rowItem.Cells[7].FindControl("ch1"));

if (chk != null && chk.Checked)
{

SqlConnection myConnection = new SqlConnection("Data Source=PCIMS051;Initial Catalog=unblockingwebsite;Integrated Security=True");
myConnection.Open();


SqlCommand myCommand = new SqlCommand("INSERT INTO twebsite_unblocking (Requested_Status) " +
"Values ('2')", myConnection);
}
}
Posted

1 solution

Use AutoPostBack="true" in design page.

like
<asp:checkbox id="CheckBox1" runat="server" autopostback="true" xmlns:asp="#unknown">

OR

Give some more explanation for the problem, your question not cleared
 
Share this answer
 
Comments
Member 9630032 27-Nov-12 22:45pm    
foreach (GridViewRow rowI
tem in GridView1.Rows)
{
CheckBox chk = (CheckBox)(rowItem.Cells[7].FindControl("ch1"));
try
{
if (chk == null)
{
Label3.Text = "hai";
SqlConnection myConnection = new SqlConnection("Data Source=PCIMS051;Initial Catalog=unblockingwebsite;Integrated Security=True");
myConnection.Open();
SqlCommand myCommand = new SqlCommand("INSERT INTO twebsite_unblocking (Requested_Status) " + "Values ('2')", myConnection);
myCommand.ExecuteNonQuery();
myConnection.Close();
}
}
catch { }

}

Update Cancel Requested_ID Requested_by Action_taken Action_remark Action_taken_by Action_taken_date Request_Status


Label text changed but check box status not changed and not update to sql

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