radgrid- edit row - Code behind

2 posts, 0 answers
  1. Manoj
    Manoj avatar
    26 posts
    Member since:
    Feb 2012

    Posted 03 Jun 2012 Link to this post

    Hi,

    I need to edit radgrid row in the code behind.

    Please help me.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Jun 2012 Link to this post

    Hi Manoj,

    You can write the code to update the RadGrid in the UpdateCommand event. Please take a look into the following code snippet.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AutoGenerateEditColumn="true" onupdatecommand="RadGrid1_UpdateCommand">
       <MasterTableView>
          <columns>
             <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" ></telerik:GridBoundColumn>
             <telerik:GridBoundColumn UniqueName="EmployeeID" DataField="EmployeeID" HeaderText="EmployeeID"></telerik:GridBoundColumn>
          </Columns>
       </MasterTableView>
    </telerik:RadGrid>

    C#:
    protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
    {
          GridEditableItem editItem = (GridEditableItem)e.Item;
          string OrderId = (editItem["OrderID"].Controls[0] as TextBox).Text;
          string EmployeeID = (editItem["EmployeeID"].Controls[0] as TextBox).Text;
          // code to update in the values in DataBase  
    }

    Thanks,
    Shinu.
Back to Top