Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Cant get user-entered values in GridView

Reply
Thread Tools

Cant get user-entered values in GridView

 
 
Arthur Dent
Guest
Posts: n/a
 
      03-13-2006
Okay, this should be really simple, and maybe im just missing something
totally obvious, but i cannot figure this out. I did this all the time in
ASP.NET 1.1 with no problems.

I have a GridView which has a column that is a template column, and has a
textbox in the itemtemplate. There is one button in the footer of the grid
for "save"; so the user can type in changes to a bunch of rows, and then
click save, and my code iterates essentially as so:

For Each gr As GridViewRow In grid.Rows: SaveRow(gr): Next

This way they can change a bunch of rows and then save instead of doing
change a row, save, change a row, save, change a row, save, change a row,
save.

So my code (pseudo-code) looks like this:

Sub btnSave_Click
For Each gr As GridViewRow in grid.Rows
Dim newValue as string =
CType(gr.FindControl("txtValue"),TextBox).Text

Dim SQL as string = "Some Sql using the new value"
ExecuteSQL
Next
End Sub

The problem is, when i get the Text property from the textbox, it gives me
the OLD value to which it was initially bound, instead of giving me the new
value which the user typed in. Why? How am i supposed to get the user's new
data?
Please HELP!!

Thanks in advance,
- Arthur Dent


 
Reply With Quote
 
 
 
 
Munawar Hussain
Guest
Posts: n/a
 
      03-14-2006
Hi,
Try it...
http://www.dotnetjohn.com/articles.aspx?articleid=83

It looks what you are looking for...

best luck
...
"Arthur Dent" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Okay, this should be really simple, and maybe im just missing something
> totally obvious, but i cannot figure this out. I did this all the time in
> ASP.NET 1.1 with no problems.
>
> I have a GridView which has a column that is a template column, and has a
> textbox in the itemtemplate. There is one button in the footer of the grid
> for "save"; so the user can type in changes to a bunch of rows, and then
> click save, and my code iterates essentially as so:
>
> For Each gr As GridViewRow In grid.Rows: SaveRow(gr): Next
>
> This way they can change a bunch of rows and then save instead of doing
> change a row, save, change a row, save, change a row, save, change a row,
> save.
>
> So my code (pseudo-code) looks like this:
>
> Sub btnSave_Click
> For Each gr As GridViewRow in grid.Rows
> Dim newValue as string =
> CType(gr.FindControl("txtValue"),TextBox).Text
>
> Dim SQL as string = "Some Sql using the new value"
> ExecuteSQL
> Next
> End Sub
>
> The problem is, when i get the Text property from the textbox, it gives me
> the OLD value to which it was initially bound, instead of giving me the
> new value which the user typed in. Why? How am i supposed to get the
> user's new data?
> Please HELP!!
>
> Thanks in advance,
> - Arthur Dent
>



 
Reply With Quote
 
 
 
 
CaffieneRush@gmail.com
Guest
Posts: n/a
 
      03-14-2006
Check to see if you've over written your gridview values in the events
before getting to your postback event handler (btnSave_Click()) and
after ASP.NET calls LoadViewState (eg. Page_Load()).

 
Reply With Quote
 
Arthur Dent
Guest
Posts: n/a
 
      03-14-2006
Yes, this was it.... in my Page_Load, i have my "If Not IsPostBack" block
commented out, ... why, who knows.

Uncommented that, and now it works as perfect.
Thanks for the "extra set of eyes"!

CheerZ!


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Check to see if you've over written your gridview values in the events
> before getting to your postback event handler (btnSave_Click()) and
> after ASP.NET calls LoadViewState (eg. Page_Load()).
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cant get data to show up on gridview Paul ASP .Net 2 03-14-2008 08:02 PM
rowupdating- I cant get values of columns - blanks- please advise =?Utf-8?B?bWFnZ2ll?= ASP .Net 1 10-25-2007 06:25 PM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
Cant get a gridview to bind to my dataset catronro@gmail.com ASP .Net Web Controls 1 12-17-2005 12:51 AM
man i cant belive i cant get help please unclejesse01 DVD Video 2 04-14-2005 03:15 PM



Advertisments