Switch between TextBox and Label inside DataGrid

J

John Smith

I have DataGrid with Label in one of its columns. Label should change into
TextBox, when user do some specific action. How can I acomplish this??


P.S. Sorry for multiple posts in the same newsgroup, but I had to do that,
because my OE news reader doesn't show all my posts.
 
J

John Smith

I'm trying this:

<asp:TemplateColumn HeaderText="Sum">
<ItemTemplate>
<asp:Label id="lblSum" runat="server" Text='<%#
Container.DataItem("Sum") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtSum" runat="server" Text='<%#
Container.DataItem("Sum") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

but when I do this:

DataGrid1.EditItemIndex = index

all DataGrid fields in selected row becomes editable and I wan't only one
specific field to be editable (TextBox). What should I do? :(
 
E

Eliyahu Goldin

You need to make an ItemTemplate including both the label and the textbox
and control their visibility depending
on user actions. For an experienced javascript programmer I would recommend
doing it on client side. Otherwise you can do it on server side, possibly
with AJAX or other similar technologies.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top