471,093 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,093 software developers and data experts.

asp.net 2.0 datagrid - update cannot get text out of textbox

New to 2.0, using code that works in 1.1, and all works well except cannot
get the text out of the textboxes for updating the database.

My template column looks like this:

<asp:TemplateColumn HeaderText="Notes"
ItemStyle-HorizontalAlign="Center">
<ItemStyle VerticalAlign="Top"></ItemStyle>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "CarlileNotes")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="txtNotes" Width="300"
MaxLength="1000" CssClass="clsBody" Text='<%#
Container.DataItem("CarlileNotes") %>' />
</EditItemTemplate>
</asp:TemplateColumn>

My code behind looks like this:

sNotes = CType(e.Item.FindControl("txtNotes"), TextBox).Text.Trim

It runs without errors but sNotes does not contain the text from the text
box.

Any help is appreciated.
Mar 9 '06 #1
2 4101
Figured it out....didn't have "If Not Page.IsPostBack Then fill the grid" in
my Page_Load event.

"cindy" wrote:
New to 2.0, using code that works in 1.1, and all works well except cannot
get the text out of the textboxes for updating the database.

My template column looks like this:

<asp:TemplateColumn HeaderText="Notes"
ItemStyle-HorizontalAlign="Center">
<ItemStyle VerticalAlign="Top"></ItemStyle>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "CarlileNotes")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="txtNotes" Width="300"
MaxLength="1000" CssClass="clsBody" Text='<%#
Container.DataItem("CarlileNotes") %>' />
</EditItemTemplate>
</asp:TemplateColumn>

My code behind looks like this:

sNotes = CType(e.Item.FindControl("txtNotes"), TextBox).Text.Trim

It runs without errors but sNotes does not contain the text from the text
box.

Any help is appreciated.

Mar 9 '06 #2
Hello cindy,

Yes, but take into account that leds the postback of the whole page. And
for grid with 10 edit fields it will be 10 postbacks.
I'd recomend u use Responce.Form to get the text from your controls when
u press submit in your grid
In that case u get only one postback

c> Figured it out....didn't have "If Not Page.IsPostBack Then fill the
c> grid" in my Page_Load event.
c>
c> "cindy" wrote:
c>
New to 2.0, using code that works in 1.1, and all works well except
cannot get the text out of the textboxes for updating the database.

My template column looks like this:

<asp:TemplateColumn HeaderText="Notes"
ItemStyle-HorizontalAlign="Center">
<ItemStyle VerticalAlign="Top"></ItemStyle>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "CarlileNotes")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="txtNotes" Width="300"
MaxLength="1000" CssClass="clsBody" Text='<%#
Container.DataItem("CarlileNotes") %>' />
</EditItemTemplate>
</asp:TemplateColumn>
My code behind looks like this:

sNotes = CType(e.Item.FindControl("txtNotes"), TextBox).Text.Trim

It runs without errors but sNotes does not contain the text from the
text box.

Any help is appreciated.

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Mar 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Randy | last post: by
1 post views Thread by siaj | last post: by
4 posts views Thread by siaj | last post: by
3 posts views Thread by Eveready | last post: by
reply views Thread by RajS | last post: by
3 posts views Thread by Sonu | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.