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

G

Guest

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.
 
G

Guest

Figured it out....didn't have "If Not Page.IsPostBack Then fill the grid" in
my Page_Load event.
 
M

Michael Nemtsev

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>---
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
 

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

Top