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

radgrid- edit row - Code behind

1 Answer 198 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Manoj
Top achievements
Rank 1
Manoj asked on 04 Jun 2012, 04:16 AM
Hi,

I need to edit radgrid row in the code behind.

Please help me.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Jun 2012, 06:33 AM
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.
Tags
General Discussions
Asked by
Manoj
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or