Hi,
place the checkbox in the item template of the grid view and make the autopostback property = true. Attach the oncheckedchanged event.
<asp:CheckBox ID="chkAdd" runat="server" AutoPostBack="true" OnCheckedChanged="chkAdd_OnCheckedChanged" />
Try to have some Add button in the screen. user should check the checkboxes and then click add, u try to add all
the rows. otherwise performance problem may occur.
public void chkStatus_OnCheckedChanged(object sender, EventArgs e)
{
datatable dtrowsAdd = new datatable();
// code for creating required columns in datatable
CheckBox chkStatus = (CheckBox)sender;
GridViewRow row = (GridViewRow)chkStatus.NamingContainer;
// create new row of the datatable dtrowsAdd and assign the gridview row values to datarow
// add the new row to the dtrowsAdd datatble and keep the datatable in session.
}
In the Add button event handler, loop the destination gridview( where u want to add rows)
and the rows in datatable. merge this datatable with the datatable in session. then assign the datatable
as source of gridview.
Meyammai
Parcha, if this helps please login to Mark As Answer. | Alert Moderator