I have data grid and I have two radio buttons in the datagrid i.e approve or reject and also one button in datagrid i.e submit
what i want to do is when approved button is selected and submit button in the datagrid is clicked for one row I want the data of that row to be stored in the database with Isactive as 1 and the row should be deleted from the datagrid, but details must be stored in the database.
Similarly when the reject button is selected and submit button in datagrid is clicked,the data of that row should be stored in the database with Isactive as 0 and the row should be deleted from the datagrid
details must be stored in the database.
The isActive is not updating in the database,I dont know hot give the Where condition for the update clause?
Can someone please tell me whats wrong in my code? The below is my C# code that i tried..
protected void submit(object sender, EventArgs e)
{
// *Get the Gridview Row* //
DataGridItem drow = (DataGridItem)(sender as Control).Parent.Parent;
RadioButton rbpApprove = (RadioButton)drow.FindControl("rbtnapprove");
RadioButton rbpReject = (RadioButton)drow.FindControl("rbtnreject");
if (rbpApprove.Checked == true)
{
conn.Open();
SqlCommand cmd = new SqlCommand("Update table set IsActive= 0 ", conn);
cmd.ExecuteNonQuery();
conn.Close();
}
else if (rbpReject.Checked == true)
{
conn.Open();
SqlCommand cmd = new SqlCommand("Update table set IsActive= 1", conn);
cmd.ExecuteNonQuery();
conn.Close();
}
string empid = dgi.Cells[0].Text;
string employeename = dgi.Cells[2].Text;
string designation = dgi.Cells[3].Text;
conn.Open();
SqlCommand comm = new SqlCommand("insert into [table] values (" + empid + ",'" + employeename + "','" + designation + "')", conn);
comm.ExecuteNonQuery();
conn.Close();
}