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

[Solved] Disable textbox in Popup Mode

3 Answers 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 13 Sep 2009, 02:50 AM
hi

I'm using radgrid for PopUp editing mode
I have two template columns.
In the "Insert" mode i want to enable the two text boxes.
But in edit - update mode i want to disable the first text box.
How can we achieve this?

This is my aspx code:

<

 

MasterTableView EditMode="PopUp" CommandItemDisplay="Top" DataKeyNames="Customer _ID" DataSourceID="sdsCustomer" Width="100%">

 

 

<Columns>

 

<

 

telerik:GridTemplateColumn DataField="Customer_ID" Visible="false" HeaderText="Customer ID"

 

 

SortExpression="Customer_ID" UniqueName="Customer_ID">

 

 

<ItemTemplate>

 

 

<asp:Label ID="Customer_IDLabel" runat="server" Text='<%# Eval("Customer_ID") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

<EditItemTemplate>

 

 

<asp:TextBox ID="Customer_IDTextBox" Width="200px" runat="server"

 

 

Text='<%# Bind("Customer_ID") %>'></asp:TextBox>

 

 

</EditItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn DataField="Customer_Name" HeaderText="Name"

 

 

SortExpression="Customer_Name" ItemStyle-Wrap="false" UniqueName="Customer_Name">

 

 

<EditItemTemplate>

 

 

<asp:TextBox ID="Customer_NameTextBox" Width="200px" runat="server"

 

 

Text='<%# Bind("Customer_Name") %>'></asp:TextBox>

 

 

</EditItemTemplate>

 

 

<ItemTemplate>

 

 

<asp:Label ID="Customer_NameLabel" runat="server"

 

 

Text='<%# Eval("Customer_Name") %>'></asp:Label>

 

 

</ItemTemplate>

 

<

 

ItemStyle Wrap="False"></ItemStyle>

 

 

</telerik:GridTemplateColumn>

 

</

 

Columns>

 



I am using this code:

 

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs)

 

If (TypeOf e.Item Is GridEditableItem) AndAlso (e.Item.IsInEditMode) Then

 

 

 

Dim edititem As GridEditableItem = DirectCast(e.Item, GridEditableItem)

 

 

Dim txtbx As TextBox = DirectCast(edititem("Customer_ID").Controls(0), TextBox)

 

 txtbx.Enabled =

False

 

 

 

End If

 

 

 

End Sub

But it don't seems to work. Thanks

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Sep 2009, 04:11 AM
Hello,

Try out the following code to disable the textbox in the EditItemTemplate of the GridTemplateColumn when the grid is in EditMode and not in Insert mode:
vb:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) 
    If (TypeOf e.Item Is GridEditableItem) AndAlso (e.Item.IsInEditMode) AndAlso (Not e.Item.OwnerTableView.IsItemInserted) Then 
        Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem) 
        Dim txtbx As TextBox = DirectCast(item.FindControl("Customer_IDTextBox"), TextBox) 
        txtbx.Enabled = False 
    End If 
End Sub 

Regards
Princy.
0
L
Top achievements
Rank 1
answered on 14 Sep 2009, 10:24 AM
hi

I tried the code and is not working.
0
Accepted
Mira
Telerik team
answered on 15 Sep 2009, 02:35 PM
Hello Lui,

To achieve the desired by you functionality I recommend that that you set the Visible property of the text box in its declaration in the shown below way:
Visible = '<%# DataBinder.Eval(Container, "OwnerTableView.IsItemInserted") %>' 

Sincerely yours,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
L
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
L
Top achievements
Rank 1
Mira
Telerik team
Share this question
or