san

san

  • NA
  • 9
  • 0

deleting rows in gridview..

Mar 3 2009 2:31 AM

after selecting the rows through checkbox in first gridview and transfering them to second gridview i want the selected rows to get deleted from the first gridview..i want to delete the rows only in the front end and not from database since i have used sql data source to fill the first gridview..is this possible..below is the code which i have used..


foreach (GridViewRow row in GridView1.Rows)
{
string upstr = "UPDATE emp SET flag = '1' WHERE empId = ";
CheckBox ch = (CheckBox)(row.FindControl("chkbx1"));

if (ch.Checked == true)
{
int Id = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
idArr.Add(Id);

upstr += "'" + Id + "'";
conn = new SqlConnection(constr);
conn.Open();
SqlCommand comm = new SqlCommand(upstr, conn);
comm.ExecuteNonQuery();
conn.Close();

GridView1.DeleteRow(Id);

//row.Visible = false;
ch.Checked = false;
}
}


when i am compiling this am getting ""Deleting is not supported by data source 'empReq' unless DeleteCommand is specified."


Answers (1)