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

2 posts, 0 answers
  1. ajmal
    ajmal avatar
    57 posts
    Member since:
    Oct 2006

    Posted 11 Jan 2011 Link to this post

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

  2. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 14 Jan 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top