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

Referencing Controls in Grid Row Edit Form

In many situations you may need to get reference to controls in grid row/edit form and modify their state depending on the option the user chooses for another control in the same row/edit form. You can reference the grid item which wraps the controls (either data item or edit form item), then locate the other control and modify its state as per your custom needs. In some cases (when having additional containers in the rows), you may need to find the container first and then propagate the same steps (depicted above).

The upcoming code sample represents how to alter the color for the City column on checkbox state change and how to load different set of items for combo in par with the user selection in another combo. Please note that the items refresh action is not included:

ASP.NET
<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" Width="400px">
  <MasterTableView AutoGenerateColumns="false">
    <Columns>
      <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Check/UnCheck">
        <ItemTemplate>
          <asp:Panel ID="Panel1" runat="server">
            <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" OnCheckedChanged="CheckedChanged" />
          </asp:Panel>
        </ItemTemplate>
      </telerik:GridTemplateColumn>
      <telerik:GridDropDownColumn UniqueName="ddlContactName" ListTextField="ContactName"
        ListValueField="CustomerID" ListDataMember="Customers" DataField="CustomerID" HeaderText="Contact name" />
      <telerik:GridBoundColumn UniqueName="City" DataField="City" HeaderText="City" />
      <telerik:GridDropDownColumn UniqueName="ddlContactTitle" ListTextField="ContactTitle"
        ListValueField="CustomerID" ListDataMember="Customers" DataField="CustomerID" HeaderText="Contact title" />
      <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" />
    </Columns>
  </MasterTableView></telerik:RadGrid>

Live example is available here.

Not finding the help you need?
Contact Support