Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2006

Tip: Looking for answers? Try searching our database.

Get data, make textBoxes, edit values, and re-save to database.  Simple?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michigan_RE_M0VE@ameritech.net - 01 Feb 2006 04:55 GMT
I'm using asp.net/vb.net/ado.net to create a very simple user interface.
(Everything works if I use STATICALLY created textBoxes... but not when I
make them DYNAMICALLY.)

1.  Execute a SQL SELECT cmd to retrieve a record.

2.  Loop through the dataReader values, creating textBox boxes dynamically,
adding them to a Panel.
(The database values are placed in these textboxes.)

3. Allow the user to edit 1 of the values in 1 of the textboxes.

4.  When he hits the SUBMIT button... it saves his changes back to the
database with an UPDATE command.

I seem to have everything working... but the values that are getting stored
at the *ORIGINAL* values
(not the new ones that user typed in.)

Seems like I can't get dynamically created controls to return the user's
*NEW* values back to the database.

Help!
ray.bradbury9@gmail.com - 01 Feb 2006 08:11 GMT
IMHO it seems that you can have done any of these two things:

1.- You create the textboxes and fill the original data in every load
of the web page. Page.IsPostBack missing in the Page_Load?
2.- You may have to add the control to the viewstate.

Anyway, I haven't done any test and you have posted no code, so nothing
is sure.

> I seem to have everything working... but the values that are getting stored
> at the *ORIGINAL* values
> (not the new ones that user typed in.)
Michigan_RE_M0VE@ameritech.net - 01 Feb 2006 14:33 GMT
I think all my code is correct...but not *WHERE* it is being called from.

My code is some VERY standard/common database stuff:

Sub LoadData()    ' Creates the new textboxes... and loads them with data
from the database

Sub SaveData()    ' Save the data back to the database

Where *SHOULD* those subs appear?

Page_Load()     ' In the "postback" section
Page_Load()    ' In the "not postback" section
Page_Init()        ' Here?

Should I be "manually" storing my data in ViewState(n) values in LoadData()?
Should I be using those ViewState(n) values in SaveData() to save the data?

I've tried a bazillion different ways... none of which seem to do anything
but "successfully" re-save the
same values that were already in the database.   (Instead of saving the
user's NEW values.)

Thanks

> IMHO it seems that you can have done any of these two things:
>
[quoted text clipped - 8 lines]
> > at the *ORIGINAL* values
> > (not the new ones that user typed in.)
ray.bradbury9@gmail.com - 01 Feb 2006 16:53 GMT
I think you are using VB:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
       If Not Page.IsPostBack Then
           Call LoadData()
       End If
   End Sub
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
       Call SaveData()
   End Sub

   Private Sub LoadData()

   End Sub
   Private Sub SaveData()

   End Sub

About the viewstate: Not sure about this but probably will be ok
setting the enableviewstate property of the textboxes before adding
them to the page.
Michigan_RE_M0VE@ameritech.net - 03 Feb 2006 04:30 GMT
When placing my LoadData() and SaveData() subs in those places... the
textboxes all contain nothing.

I won't post 100s of lines of code... but seems like the problem area is
most likely:

My LoadData() sub gets the text from the database... and places it in the
newly created Panel1.txtBox0.Text (and 1,2,3) controls
(And also stores it in ViewState(0), ViewState(1), ViewState(2), etc.)

My SaveData() sub tries to save the values ViewState(0), ViewState(1),
etc....
(It can't find Panel1.txtBox0.Text (and 1,2,3) controls... because they are
created "on the fly".)

Doesn't seem to work if I try to manipulate ViewState(n) in my code... or
let the system do it automatically.

:-(

>I think you are using VB:
>
[quoted text clipped - 19 lines]
> setting the enableviewstate property of the textboxes before adding
> them to the page.
ray.bradbury9@gmail.com - 13 Feb 2006 16:32 GMT
a few days ago I saw a FAQ about viewstate in eggheadcaffe. I don´t
remember it, but think that talked about dinamically created controls
and viewstate. hope it helps.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.