473,387 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 4194
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Randy | last post by:
Hello All, I'm trying to discover the best way to handle the situation where you have a datagrid in your app and someone changes a cell but doesn't leave that cell (so there's the little pencil...
1
by: siaj | last post by:
Helo All, If some one has faced a similar issue.. My datagrid Update command is not getting fired in fact it seems that the no event fires on clicking the update link. Although the cancel and the...
4
by: siaj | last post by:
Hello All, If some one has faced a similar issue.. My datagrid Update command is not getting fired in fact it seems that the no event fires on clicking the update link. Although the cancel and the...
1
by: John Davis | last post by:
I am writing a program that allows user to select the date in a calendar, and it will update the text fields automatically. I created 2 forms. The first form has 2 text fields (start date and...
3
by: Eveready | last post by:
Hi, I would like to have datagrid update all rows by clicking one button. I need to know how to cycle through each row and get the value in the 3rd column. Any help is appreciated. thnx...
0
by: RajS | last post by:
Hi All, I am trying to update datagrid, onTextchanged event, I dont know how to do this. please shed some light or any examples. Here is the code I am wrestling with. OnTextChanged event of...
1
by: jaffar | last post by:
hi, i am developing an appllication, in this appllication i am using datagrid . in this datagrid coloumns header text i want to change coloumn header text in vertically it means datagrid...
4
by: faiyeah | last post by:
Private Sub PubName_AfterUpdate() Dim sql As String sql = "select PubCode from Publisher where PubName = '" & PubName.Value & "';" Set rst = CurrentDb.OpenRecordset(sql) MsgBox sql If Not...
3
by: Sonu | last post by:
Hello, I have a winform1 that contains the Datagrid and in winform2 you can add new values to the database for datagrid. I cannot update the datagrid on winform2 close event! All I want is to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.