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

TextBox onlyRead in editMode but editable on create row

2 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hansel Eduard
Top achievements
Rank 1
Hansel Eduard asked on 23 Apr 2016, 10:46 PM

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 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 27 Apr 2016, 11:47 AM
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.
0
Hansel Eduard
Top achievements
Rank 1
answered on 28 Apr 2016, 02:59 AM
Thank you so much! Works great ..
Tags
Grid
Asked by
Hansel Eduard
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Hansel Eduard
Top achievements
Rank 1
Share this question
or