how to get updated template column value from datagrid

H

headbig003

Hello

I put template column in datagrid. Below is the html code I used.

<asp:datagrid id="dgAnswer" runat="server" Width="360px"
AutoGenerateColumns="False" DataKeyField="ansID">
<Columns>
<asp:TemplateColumn HeaderText="Answer Text">
<ItemTemplate>
<asp:TextBox id="txtItem" runat="server" Width="201px" Text='<%#
DataBinder.Eval(Container.DataItem, "ansDescription") %>'
MaxLength="100">
</asp:TextBox>
</ItemTemplate>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

I use code behind to populate the datagrid using dataset.
Populating datagrid part is working fine, but when I tried to update
the textbox and tried to save it. Updated information doesn't save.

I would like to know how to get updated information from template
column.

I spent whole day to figure this out. I am exhausted and feel so
stupid.

Please help.....

p.s. Code behind C#.
 
E

Elton Wang

Hi there,

If your application shows no error but update nothing, the
most likely reason is that you bind the datagrid's data
source every time, no matter it's first loading or post
back. Your updating OP is in postback step. Since you
probably re-bind the data source, the datagrid's data are
refilled with data from db. So how do you expect it can
perform updating?

If it's not true, please post your code.


HTH


Elton Wang
(e-mail address removed)
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top