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

ID of GridCheckboxColumn

4 Answers 240 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 22 Sep 2014, 05:26 PM
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.

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 22 Sep 2014, 06:39 PM
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
0
Kyle
Top achievements
Rank 1
answered on 22 Sep 2014, 07:59 PM
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.

0
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Sep 2014, 07:55 AM
Hi,

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

Thanks,
Jayesh Goyani
0
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Sep 2014, 05:44 PM
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
Tags
Grid
Asked by
Kyle
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Kyle
Top achievements
Rank 1
Share this question
or