Change ItemTemplate binding code behind

2 posts, 0 answers
  1. Patrick
    Patrick avatar
    11 posts
    Member since:
    May 2009

    Posted 16 May Link to this post


    I would like to change the binding of the ItemTemplate of a GridTemplateColumn in code behind. I am trying to use the click event of a button outside of the grid to change the binding. On the button click, I would like change the Text value of the ItemTemplate to '<%#Eval("Choose")%>'. Please assist.


    <telerik:GridTemplateColumn HeaderText="SSA Decision" SortExpression="SSA_Decision" UniqueName="SSA_Decision">
        <asp:Label ID="lblSSADecision" runat="server" Text='<%#Eval("SSA_Decision")%>' />
        <telerik:RadComboBox runat="server" ID="cboSSADecision" Skin="WebBlue" Width="105px">
                <telerik:RadComboBoxItem Text="Yes" Value="True" />
                <telerik:RadComboBoxItem Text="No" Value="False" />
                <telerik:RadComboBoxItem Text="Please Choose" Value="Choose" Selected="true" />


  2. Eyup
    Eyup avatar
    3009 posts

    Posted 19 May Link to this post

    Hi Patrick,

    Generally, you can define 2 Label controls and toggle their Visible property depending on the chosen option. Alternatively, you can remove the Text property from the mark-up definition and use the ItemDataBound event handler to set the text using the labelControl.Text=DataBinder.Eval(gridDataItem.DataItem, "FieldName") approach:

    I hope this will prove helpful.

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top