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."
ArshadPosted Mar 13, 2009, 5:30 AM
As per my knowledge, you add one more colum in the databse by the name of Bit_Recyclybin, and while fetching the data you jus check like select * from table name where Bit_Recyclybin=0; and while deleting you dont want to delete that recored from database right? so for that you show delete from the aspx page but you update that record to the Bit_Recyclybin=1; thats all
Thanks.