0

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

Edited by mike_2000_17: Fixed formatting

3
Contributors
4
Replies
12
Views
7 Years
Discussion Span
Last Post by Mortimertefo
0

Ne other simple method will also do.....please suggest....i need it urgently....


Cya
Rohan

0

do you have remove button for each row in gridview or a single remove button ?

Ne other simple method will also do.....please suggest....i need it urgently....


Cya
Rohan

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.