how to get updated template column value from datagrid

  • Thread starter Thread starter headbig003
  • Start date Start date
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#.
 
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)
 
Back
Top