radgrid text box template column set focus

3 posts, 0 answers
  1. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 09 Oct 2012 Link to this post

    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!
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 10 Oct 2012 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 10 Oct 2012 Link to this post

    I works. Thanks Jayesh!
Back to Top