|
-
Jul 25th, 2007, 11:55 PM
#1
Thread Starter
Fanatic Member
[RESOLVED]textbox in GridView not getting new value
using:
-asp.net 2.0
-Visual Studio 2005
I have a gridview and one column has a textbox that can be edited in the gridview at all times. There is no Edit/Update/Delete columns here.
From my business object (List) I'll bind it to the Grid.
If I originally bind the value 3 to this textbox it displays correctly. When I change this 3 to another number, 5 for instance... and then use:
Code:
dim s as string =DirectCast(row.Cells(2).FindControl("QuantityTextBox"), TextBox).Text
to get the new value of 5 and place it back into the List object
the value is still 3 and not 5.
I've used this method many times before and with no problems.
I don't know why it isn't working here.
This is driving me nuts. Any ideas?
markup piece looks like this:
Code:
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate >
<asp:TextBox ID="QuantityTextBox" runat="server" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
Last edited by ZeBula8; Jul 30th, 2007 at 06:03 PM.
Reason: [RESOLVED]
-
Jul 27th, 2007, 12:55 AM
#2
Re: textbox in GridView not getting new value
You've used a template field, and put a textbox in there. Good. When are you running that code to read from the textbox? What event?
-
Jul 28th, 2007, 08:38 PM
#3
Thread Starter
Fanatic Member
Re: textbox in GridView not getting new value
[please ignore the mulitple duplicate posts - something with the server was stalling and my clicks ended up - moderator might want to look at the cause and effect of double-clicking the 'Submit post' button.)
i should be able to run this code at any time to get the value from the textbox.
Code:
for each row as gridviewrow in gridview1.rows
dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
next
I have done it this way in the past without a hitch...
Last edited by ZeBula8; Jul 28th, 2007 at 10:13 PM.
-
Jul 28th, 2007, 08:38 PM
#4
Thread Starter
Fanatic Member
Re: textbox in GridView not getting new value
i should be able to run this code at any time to get the value from the textbox.
Code:
for each row as gridviewrow in gridview1.rows
dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
next
I have done it this way in the past without a hitch...
-
Jul 28th, 2007, 08:39 PM
#5
Thread Starter
Fanatic Member
Re: textbox in GridView not getting new value
i should be able to run this code at any time to get the value from the textbox.
Code:
for each row as gridviewrow in gridview1.rows
dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
next
I have done it this way in the past without a hitch...
-
Jul 28th, 2007, 08:39 PM
#6
Thread Starter
Fanatic Member
Re: textbox in GridView not getting new value
i should be able to run this code at any time to get the value from the textbox.
Code:
for each row as gridviewrow in gridview1.rows
dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
next
I have done it this way in the past without a hitch...
-
Jul 28th, 2007, 08:39 PM
#7
Thread Starter
Fanatic Member
Re: textbox in GridView not getting new value
i should be able to run this code at any time to get the value from the textbox.
Code:
for each row as gridviewrow in gridview1.rows
dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
next
I have done it this way in the past without a hitch...
-
Jul 28th, 2007, 08:39 PM
#8
Thread Starter
Fanatic Member
Re: textbox in GridView not getting new value
i should be able to run this code at any time to get the value from the textbox.
Code:
for each row as gridviewrow in gridview1.rows
dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
next
I have done it this way in the past without a hitch...
-
Jul 28th, 2007, 08:39 PM
#9
Thread Starter
Fanatic Member
Re: textbox in GridView not getting new value
i should be able to run this code at any time to get the value from the textbox.
Code:
for each row as gridviewrow in gridview1.rows
dim sNewValue as string = ctype(row.cells(2).findcontrol("mytextbox"),textbox).text
next
I have done it this way in the past without a hitch...
-
Jul 30th, 2007, 05:54 AM
#10
Re: textbox in GridView not getting new value
Is the gridview being repopulated in the Page Load event without a postback check?
-
Jul 30th, 2007, 06:01 PM
#11
Thread Starter
Fanatic Member
Re: textbox in GridView not getting new value
It was in fact that the gridview was being repopulated in the Page Load - thank you mendhak!
-
Aug 1st, 2007, 10:24 AM
#12
Re: [RESOLVED]textbox in GridView not getting new value
Woohoo, I can read minds without reading code!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|