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

radgrid text box template column set focus

3 Answers 285 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 1
JJ asked on 10 Oct 2012, 12:48 AM
I have a grid , have one GridTemplateColumn has a text box
<telerik:GridTemplateColumn   UniqueName="ForeignTranslation" AllowFiltering="true" FilterControlWidth="70px" 
HeaderText="dd">
<ItemTemplate>
        <asp:TextBox ID="txtTranslationText"  AutoPostBack="true" runat="server" Height="44px" OnTextChanged="txtTranslationText_TextChanged" TextMode="MultiLine"  ></asp:TextBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
 OnTextChanged will save the data to DB

I need to allow user to tab out to the next row of the text box and set focus to the next row text box.
on Itemdatabound, I used
TextBox tb = (TextBox)dataItem["ForeignTranslation"].FindControl("txtTranslationText");
tb.TabIndex = 1;
It will allow me to tab out to the next row text box fine if I don't do any edit, as long as I change the text in the text box, which fires  OnTextChanged, then, the form did post back and the focus lost.

Is there anyway I can make the focus to the next row of text box in the grid after OnTextChanged triggered?

How can I find thegrid  next row clientID on OnTextChanged??


Thanks!

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Oct 2012, 05:01 AM
Hello,

Please try with below code snippet.

<telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:TextBox ID="txtTranslationText" AutoPostBack="true" runat="server" Height="44px"
                               OnTextChanged="txtTranslationText_TextChanged" TextMode="MultiLine"></asp:TextBox>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
protected void txtTranslationText_TextChanged(object sender, EventArgs e)
    {
        GridDataItem citem = (sender as TextBox).NamingContainer as GridDataItem;
 
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
        {
            if (item.ItemIndex == citem.ItemIndex + 1)
            {
                (item.FindControl("txtTranslationText") as TextBox).Focus();
            }
        }
        
    }


Thanks,
Jayesh Goyani
0
JJ
Top achievements
Rank 1
answered on 10 Oct 2012, 04:45 PM
I works. Thanks Jayesh!
0
Omar
Top achievements
Rank 1
answered on 04 Jul 2017, 05:58 PM
it works thanks
Tags
Grid
Asked by
JJ
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
JJ
Top achievements
Rank 1
Omar
Top achievements
Rank 1
Share this question
or