Q. Insert checkbox and textbox in grid view and create a column in data base table named "Attendence" when a user Select the record using checkbox and input present/absent in textbox should be reflected to the database table.
Update Selection(button)
Code-
{
string s = @"Data Source=49.50.88.43;Initial Catalog=grkistdb;Persist Security Info=True;User ID=grkistuser;Password=q2oR5w_356";
cn = new SqlConnection(s);
cn.Open();
foreach (GridViewRow gr1 in GridView1.Rows)
{
CheckBox c1 = (CheckBox) gr1.FindControl("cb1");
TextBox t1 = (TextBox)gr1.FindControl("tb1");
if (c1.Checked)
{
string q = "update Chitransh_reg set Attendance ='" + t1.Text + "' where roll='"+gr1.Cells[1].Text+"'";
cm = new SqlCommand(q, cn);
cm.ExecuteNonQuery();
}
}
}
Comments
Post a Comment