hello,
I add rows to the Gridview through the following code : The below code is working fine.
However,i am now placing a button REMOVE besides this grid. Whenever a user selects a particular row ( no use of checkbox for selection) The user will click on the row he wants to remove, and clicks on the remove button , that particular row should be removed from the grid. How to achieve this??? Please help......
DataTable dt = new DataTable();
dt.Columns.Add("id");
dt.Columns.Add("HR");
dt.Columns.Add("Remarks");
if (gvwHR.Rows.Count > 0)
{
foreach (GridViewRow rows in gvwHR.Rows)
{
DataRow newrow = tblHR.NewRow();
newrow["id"] = gvwHR.DataKeys[rows.RowIndex].Value;
newrow["HR"] = rows.Cells[0].Text;
newrow["Remarks"] = rows.Cells[1].Text;
tblHR.Rows.Add(newrow);
}
}
DataRow rowH = tblHR.NewRow();
rowH ["id"] = ddlH.SelectedValue;
rowH ["HardwareRequired"] = ddlH.SelectedItem.Text;
rowH ["Remarks"] = txtHR.Text;
tblHR.Rows.Add(rowH );
tblHR.AcceptChanges();
gvwHR.DataSource = tblHR.DefaultView;
gvwHR.DataBind();
dt = null;
WAITING FOR RESPONSE.....:)
CYA
ROHAN