Hi.
I have a radgrid with a GridTemplateColumn containing a EditItemTemplate with a RadNumerictextBox named UserNrTb like this:
<telerik:RadGrid ID="RadGrid1" runat="server" ......
<Columns>
<telerik:GridTemplateColumn DataField="UserNr" DataType="System.Int32" HeaderText="UserNr" UniqueName="UserNr" >
<EditItemTemplate>
<telerik:RadNumericTextBox ID="UserNrTb" runat="server" DbValue='<%# Bind("UserNr") %>'></telerik:RadNumericTextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label runat="server" ID="UserNrLbl" Text='<%# Eval("UserNr") %>' ></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridNumericColumn DataField="Account" DataType="System.Int32" HeaderText="Account" UniqueName="column2">
</telerik:GridNumericColumn>
......
I want to have focus on the field UserNrTb in editmode but I don't know how to iterate the GridTemplateColumn. I have read the article "Focus the text boxes in the edit control" and the description work fine for GridNumericColumn as followed:
I have a radgrid with a GridTemplateColumn containing a EditItemTemplate with a RadNumerictextBox named UserNrTb like this:
<telerik:RadGrid ID="RadGrid1" runat="server" ......
<Columns>
<telerik:GridTemplateColumn DataField="UserNr" DataType="System.Int32" HeaderText="UserNr" UniqueName="UserNr" >
<EditItemTemplate>
<telerik:RadNumericTextBox ID="UserNrTb" runat="server" DbValue='<%# Bind("UserNr") %>'></telerik:RadNumericTextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label runat="server" ID="UserNrLbl" Text='<%# Eval("UserNr") %>' ></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridNumericColumn DataField="Account" DataType="System.Int32" HeaderText="Account" UniqueName="column2">
</telerik:GridNumericColumn>
......
I want to have focus on the field UserNrTb in editmode but I don't know how to iterate the GridTemplateColumn. I have read the article "Focus the text boxes in the edit control" and the description work fine for GridNumericColumn as followed:
protected void RadGrid1_ItemDataBound(object
sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem form = (GridEditableItem)e.Item;
RadNumericTextBox dataField = (RadNumericTextBox)form["column2"].Controls[0];
dataField.Focus();
}
}
I tried to do the same for the field UserNrTb but it's not working. So how can i find the field from GridTemplateColumn?
Ceci
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem form = (GridEditableItem)e.Item;
RadNumericTextBox dataField = (RadNumericTextBox)form["column2"].Controls[0];
dataField.Focus();
}
}
I tried to do the same for the field UserNrTb but it's not working. So how can i find the field from GridTemplateColumn?
Ceci