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

GridBoundColumn and UniqueName

1 Answer 1121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
IT
Top achievements
Rank 2
IT asked on 06 Jul 2010, 04:59 PM
My company utilizes some custom library routines for validation on input controls.  To use these, I have to know the control's id.  I was able to work with the id naming conventions for some column types because they will use the UniqueName as a portion of the id (such as GridDropDownColumn / RadComboBox and GridNumericColumn / RadNumericTextBox), but the GridBoundColumn does not use the UniqueName property to render the textbox id.

Is there a way to force it to use the UniqueName property? Or is there another column type to use for plain text input that will respect setting this property?

Example code:
<telerik:GridBoundColumn DataField="LineNotes" DataType="System.String" 
HeaderText="Notes" SortExpression="LineNotes" UniqueName="LineNotes">  
</telerik:GridBoundColumn> 
 
renders as  
 
<input name="RadGrid1$ctl00$ctl02$ctl03$ctl00" type="text"/> 


Thanks for any help or ideas you can provide.

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 09 Jul 2010, 12:16 PM
Hi Sundance,

The UniqueName property of the grid columns is used to uniquely identify a column in the collection of all grid columns. It is also used to find a specific column by its unique name, as well as find the edit controls for a column in the edited item. The columns do not guarantee any particular ID for the server-side controls that are initialized in their cells.

You can get the server IDs of the edit form controls using RadGrid's ItemCreated event. You can find each cell in the edit item corresponding to a particular column (using the column's UniqueName again) and get the first child control in the cell. This is the edit form control (TextBox, RadDatePicker, RadComboBox, etc.) and you can get its ID:
Copy Code
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem item = (GridEditableItem)e.Item;
        var Column1EditorControlID = item["Column1"].Controls[0].ID;
        //Column1 is the UniqueName of the column whose edit form control
        //ID you need. The first control in the edit form cell corresponding
        //to this control is the field editor control corresponding to the column
    }
}


Greetings,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
IT
Top achievements
Rank 2
Answers by
Veli
Telerik team
Share this question
or