7 Replies - 2097 Views - Last Post: 23 December 2010 - 12:38 PM Rate Topic: -----

#1 mikec  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-December 10

populating a form with data from a SQL server, then updating

Posted 22 December 2010 - 12:21 PM

Hello, I wrote a form which so far just consists of text fields and checkboxes. The data from previous entries is loaded when the page loads and then I set the values of each field (for example, contactname.Text = dbread["contactname"].ToString()). The problem is that when I populate the fields on page load, the stored procedure I'm using to update the values uses this information rather than the information actually current in the TextBoxes. I want users to be able to change and update the information, but also have it preloaded with the last data they submitted. When I comment out populating the form in the page load, the update stored procedure works as expected. Any advice would be greatly appreciated.

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: populating a form with data from a SQL server, then updating

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4437
  • View blog
  • Posts: 7,713
  • Joined: 08-June 10

Re: populating a form with data from a SQL server, then updating

Posted 22 December 2010 - 12:35 PM

Quote

on page load


This leads me to believe you are working with ASP.NET? Are you? If so, I'll move this to the ASP.NET forum where you might get better help.
Was This Post Helpful? 0
  • +
  • -

#3 mikec  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-December 10

Re: populating a form with data from a SQL server, then updating

Posted 22 December 2010 - 12:40 PM

Yes, I am using .NET. Thanks.
Was This Post Helpful? 0
  • +
  • -

#4 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4437
  • View blog
  • Posts: 7,713
  • Joined: 08-June 10

Re: populating a form with data from a SQL server, then updating

Posted 22 December 2010 - 12:42 PM

...yes, but specifically what? ASP.NET, Windows Forms, Silverlight, WPF, Windows Phone 7, WCF, Console Application, Windows Service...

All of those are ".NET".
Was This Post Helpful? 0
  • +
  • -

#5 mikec  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-December 10

Re: populating a form with data from a SQL server, then updating

Posted 22 December 2010 - 12:53 PM

Sorry, it is ASP.NET
Was This Post Helpful? 0
  • +
  • -

#6 keakTheGEEK  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 107
  • View blog
  • Posts: 344
  • Joined: 23-February 10

Re: populating a form with data from a SQL server, then updating

Posted 22 December 2010 - 02:26 PM

You want to familiarize yourself with datasource controls and databinding to user interface controls. ASP .NET already provides server controls that have built-in features to interact with a database and do what it is you are trying to do manually. Here is a tutorial that walks you through this using a FormView control. Once you get familiar with the basics of using databound controls, you can then apply it to any of the provided controls in ASP .NET. The following links also provide more information on the different databound controls that ASP .NET has to offer:
Data Controls Quick Tutorials
ASP.NET Data-Bound Web Server Controls Overview
Was This Post Helpful? 0
  • +
  • -

#7 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 441
  • View blog
  • Posts: 1,488
  • Joined: 28-April 09

Re: populating a form with data from a SQL server, then updating

Posted 22 December 2010 - 03:49 PM

post your page load code
Was This Post Helpful? 0
  • +
  • -

#8 Guest_mikec*


Reputation:

Re: populating a form with data from a SQL server, then updating

Posted 23 December 2010 - 12:38 PM

Hi, thanks for the replies. I found that the problem was I was lacking a "if(!IsPostBack)" before I populated the form with the information that exists in the database. Now that I have added that the page is working as expected.

Thanks,
Mike
Was This Post Helpful? 0

Page 1 of 1