This is a migrated thread and some comments may be shown as answers.

Read the values from a Data Grid(Contianing many Rows)

1 Answer 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ajmal
Top achievements
Rank 1
ajmal asked on 11 Jan 2011, 09:19 AM
I have a row in DataGrid that  contains a one TextBox and one Combobox control and grid has a bottun(Add Row).   On clicking  on this button(Add Row), dynamically a new Row is generated below with the same controls(TextBox and Combobox ).

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();

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 14 Jan 2011, 10:45 AM
Hello Ajmal,

I'm not sure that I understand your scenario completely. You are trying to insert multiple items simultaneously, right? If this is so, could you please post some more information about your approach? This way I will be able to provide to-the-point answer.

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
ajmal
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or