Version: 2008
  • On CBS MoneyWatch: Report: DON'T Buy the iPhone 4
Advanced Search
advertisement

Forum display:

Coding & scripting: problem editing/adding rows in datagrid c# asp.net

by tyrant - 1/26/05 11:41 PM
Post 1 of 2

problem editing/adding rows in datagrid c# asp.net

by tyrant - 1/26/05 11:41 PM

Hi,

I am trying to update a datagrid row inline.
I got my ASPX page like this ...

<asp:TemplateColumn HeaderText="Title">
<ItemTemplate>
<asp:Label id="Label5" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Title") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="add_Title" runat="server" BackColor="blue"></asp:TextBox> </FooterTemplate>
<EditItemTemplate>
<asp:TextBox id="edit_Title1" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Title") %>'>
</asp:TextBox></EditItemTemplate>
</asp:TemplateColumn>

As you can see i got 3-4 colums in this way..I get into editable mode where the textboxes appear with data.
But when i change the data using the following code..

TextBox txtTitle=(TextBox)e.Item.FindControl("edit_Title1");
string strTitle=txtTitle.Text;

The string returns is always the Old data..just doesnt pick up the changed data..this is the problem:i cannot get the changed data ..
Same issue with Add..Is the datagrid not able to get the changed data from the control..

Using ASP.NET c#

Post 2 of 2

Re: problem editing/adding rows in datagrid c# asp.net

by David Solum - 2/7/05 6:16 AM In reply to: problem editing/adding rows in datagrid c# asp.net by tyrant

The new contents are in the *first cell* of e.Item:
e.Item.Cells[0]

To get the text directly, use:
e.Item.Cells[0].Text

I hope that helps.

Dave

Forum legend:
Locked Locked thread
Moderator Moderator
CNET staff CNET staff
Samsung staff Samsung staff
Norton Authorized Support team Norton Authorized Support team
AVG staff AVG staff
Windows Outreach team Windows Outreach team
Dell staff Dell staff
Intel staff Intel staff
Powered by Jive Software