ID of GridCheckboxColumn

5 posts, 0 answers
  1. Kyle
    Kyle avatar
    7 posts
    Member since:
    Apr 2012

    Posted 22 Sep 2014 Link to this post

    I have the following columns in a RadGrid

    <telerik:GridBoundColumn DataField="NavigateTarget" HeaderText="Navigate Target" UniqueName="NavigateTarget" DataType="System.String" ColumnEditorID="Editor_NavigateTarget" />    
    <telerik:GridCheckboxColumn DataField="Enabled" HeaderText="Enabled" UniqueName="Enabled" DataType="System.Boolean" ColumnEditorID="Editor_Enabled" />    

     which, when rendered in in-place edit mode, looks like this:
      

    Note that for the first (string) column, the input id ends with TB_NavigateTarget. Presumably, TB stands for TextBox and it inferred the rest from the DataField or UniqueName. 

    For the second (checkbox) column, the input id ends with ctl00, totally ignoring the DataField, UniqueName and ColumnEditorID specified in the markup. I was expecting something like Editor_Enabled or CB_Enabled 

    So, two questions:

    1. What is the ColumnEditorID property supposed to do? It is not affecting the ID of the INPUT elements.
    2. How do I get a meaningful ID on the CheckBox? I need it for when the _UpdateCommand event is fired. 

    I also have a GridNumericColumn and it behaves similar to the GridBoundColumn, i.e. it has a meaningful ID (RNTB_<data field>) so I know that it's not a GridBoundColumn vs. specific-type column issue.

    Thanks.
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 22 Sep 2014 in reply to Kyle Link to this post

    Hi,

    Please try with the below code snippet.

    protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
    {
        GridEditableItem item = e.Item as GridEditableItem;
        TextBox txt = item["NavigateTarget"].Controls[0] as TextBox;
        CheckBox chk = item["Enabled"].Controls[0] as CheckBox;
        // you can access textbox and textbox using column unique name
    }


    Let me know if any concern.

    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kyle
    Kyle avatar
    7 posts
    Member since:
    Apr 2012

    Posted 22 Sep 2014 in reply to Jayesh Goyani Link to this post

    Jayesh, Thank you, that works well for the In-Place editor. Can you tell me the best way to do the same when using the generated EditForm?

    I don't use ExtractValuesFromItem because I have template columns.

  5. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 23 Sep 2014 in reply to Kyle Link to this post

    Hi,

    Can you please provide your aspx page code / mark up code?

    Thanks,
    Jayesh Goyani
  6. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 23 Sep 2014 in reply to Jayesh Goyani Link to this post

    Hi,

    Method 1:

    <Columns>
                           
                           <telerik:GridTemplateColumn>
                               <EditItemTemplate>
                                   <asp:TextBox ID="txtNavigateTarget" runat="server"></asp:TextBox>
                               </EditItemTemplate>
                           </telerik:GridTemplateColumn>
                           <telerik:GridTemplateColumn>
                               <EditItemTemplate>
                                   <asp:CheckBox ID="chkEnabled" runat="server"></asp:CheckBox>
                               </EditItemTemplate>
                           </telerik:GridTemplateColumn>
                       </Columns>

    protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
      {
          GridEditableItem item = e.Item as GridEditableItem;
          TextBox txt = item.FindControl("txtNavigateTarget") as TextBox;
          CheckBox chk = item.FindControl("chkEnabled") as CheckBox;
          // you can access textbox and textbox using column unique name
      }

    Method 2:

    protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
       {
           GridEditFormItem item = e.Item as GridEditFormItem;
           TextBox txt = item.FindControl("txtNavigateTarget") as TextBox;
           CheckBox chk = item.FindControl("chkEnabled") as CheckBox;
           // you can access textbox and textbox using column unique name
       }
    <EditFormSettings EditFormType="Template">
                           <FormTemplate>
                               <asp:TextBox ID="txtNavigateTarget" runat="server"></asp:TextBox>
                               <asp:CheckBox ID="chkEnabled" runat="server"></asp:CheckBox>
                           </FormTemplate>
                       </EditFormSettings>

    Let me know if any concern.


    Thanks,
    Jayesh Goyani
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017