If the datagrid as of above, with many rows(2 or more) are there , how to get all the values to be stored into database on clicking a button (Save).
How can we store row by row into a collection of class and pass that class at once to finally save into database.
Currently I'm reading each row by below code,
dtUsers.Columns.Add(
new DataColumn("TranTypeName", typeof(String)));
dtUsers.Columns.Add(
new DataColumn("ApprDlgtTranTypeKey", typeof(Decimal)));
dtUsers.Columns.Add(
new DataColumn("ApprDlgtDelegatedTo", typeof(String)));
dtUsers.Columns.Add(
new DataColumn("ApprDlgtKey", typeof(Decimal)));
delegation.ApprDlgtTranTypeKey = ((
DropDownList)e.Item.FindControl("cboFor")).SelectedValue;
delegation.TranTypeName =
Convert.ToString(((DropDownList)e.Item.FindControl("cboFor")).SelectedItem);
delegation.ApprDlgtDelegatedTo = ((
TextBox)e.Item.FindControl("txtDelegatedTo")).Text.Trim();
delegation.ApprDlgtKey =
"0";
DataRow drUser = dtUsers.NewRow();
drUser[
"ApprDlgtTranTypeKey"] = delegation.ApprDlgtTranTypeKey;
drUser[
"TranTypeName"] = delegation.TranTypeName;
drUser[
"ApprDlgtDelegatedTo"] = delegation.ApprDlgtDelegatedTo;
drUser[
"ApprDlgtKey"] = delegation.ApprDlgtKey;
dtUsers.Rows.Add(drUser);
grdDelegation.DataSource = dtUsers;
grdDelegation.DataBind();