TextBox onlyRead in editMode but editable on create row

3 posts, 0 answers
  1. Hansel Eduard
    Hansel Eduard avatar
    9 posts
    Member since:
    Apr 2016

    Posted 23 Apr Link to this post

    Hello,

    please help me!

    I need set the TextBox no-editable when the row is in EditMode but editable when iadd a new row

    here it is a part of my code:

    <telerik:GridTemplateColumn HeaderStyle-Width="150px" UniqueName="txtID" HeaderText="ID del Servicio">
                                    <ItemTemplate>
                                        <%# Eval("IdServicio") %>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox runat="server" ID="textID" Text='<%# Eval("IdServicio") %>' width="145px" ReadOnly="true"/>
                                        <asp:RequiredFieldValidator runat="server" ControlToValidate="textID" />
                                        <asp:CompareValidator runat="server" ControlToValidate="textID" Operator="DataTypeCheck" Type="Integer" />
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 27 Apr Link to this post

    Hi Hansel,

    If you would like to have editable TextBox only in Insert mode you can define only InserItemTemplate for the template column.

    <telerik:GridTemplateColumn HeaderStyle-Width="150px" UniqueName="txtID" HeaderText="ID del Servicio">
        <ItemTemplate>
            <%# Eval("IdServicio") %>
        </ItemTemplate>
        <InsertItemTemplate>
            <asp:TextBox runat="server" ID="textID" Text='<%# Eval("IdServicio") %>' Width="145px" ReadOnly="true" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="textID" />
            <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="textID" Operator="DataTypeCheck" Type="Integer" />
        </InsertItemTemplate>
    </telerik:GridTemplateColumn>

    Give the approach a try and see how it works for you.


    Regards,
    Viktor Tachev
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hansel Eduard
    Hansel Eduard avatar
    9 posts
    Member since:
    Apr 2016

    Posted 27 Apr in reply to Viktor Tachev Link to this post

    Thank you so much! Works great ..
Back to Top