New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Customizing the Appearance of Auto-generated Action Buttons

In some scenarios you may want to get a hold on the auto-generated action buttons (update/insert/cancel) inside the auto-generated grid edit form (EditMode = InPlace or EditForms) and modify them a bit without changing the entire layout of the edit form (which is possible with WebUserControl or FormTemplate custom edit form). Here are the steps to accomplish this task programmatically with several lines of code:

  1. Subscribe to the ItemCreated event of RadGrid

  2. Check whether the currently created item is in edit or insert mode

  3. Find the button of interest by its id (UpdateButton, PerformInsertButton or CancelButton) and alter its setting in par with your preferences

Below is a simple example which changes the text and some of the styles for those buttons:

ASP.NET
<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AllowSorting="True"
  Skin="Office2007" GridLines="None" Width="95%">
  <MasterTableView Width="100%" DataKeyNames="CustomerID" CommandItemDisplay="Top"
    AutoGenerateColumns="false">
    <Columns>
      <telerik:GridBoundColumn UniqueName="CompanyName" DataField="CompanyName" HeaderText="Company name" />
      <telerik:GridBoundColumn UniqueName="ContactName" DataField="ContactName" HeaderText="Contact name" />
      <telerik:GridBoundColumn UniqueName="ContactTitle" DataField="ContactTitle" HeaderText="Contact title" />
      <telerik:GridEditCommandColumn />
    </Columns>
  </MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
   SelectCommand="SELECT * FROM [Customers]">
</asp:SqlDataSource>
Not finding the help you need?
Contact Support