3 Replies - 1266 Views - Last Post: 10 April 2013 - 11:29 AM Rate Topic: -----

#1 Lukeoooo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 28-March 13

Load fields from database

Posted 08 April 2013 - 06:54 AM

Managed to make a form that allows the user to enter details using html textfields and then use Request.form("field") to save the details to the database. Now if this "About page" has already been filled in, I want to be able to load the values into the html textfields from the databse to allow the user to edit the details. Not quite sure how I can databind my text fields in the html?
Is This A Good Question/Topic? 0
  • +

Replies To: Load fields from database

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1057
  • View blog
  • Posts: 4,097
  • Joined: 02-July 08

Re: Load fields from database

Posted 08 April 2013 - 10:36 AM

The GridView has the ability to show and allow editing of your data.
Was This Post Helpful? 1
  • +
  • -

#3 McSick  Icon User is offline

  • D.I.C Head

Reputation: 33
  • View blog
  • Posts: 179
  • Joined: 02-September 10

Re: Load fields from database

Posted 10 April 2013 - 09:17 AM

You don't have to databind text fields. Grab the data from the database and most input object have a Text property you can edit. See psuedo code below!

PageLoad()
{
  data = getSomeDataFromDatabase();
  input1.Text = data.columnToSave; //Parse data basically

}




Things to look out for, make the text field or input have an id! You will use that id to access the Text property in your code. Make sure that your text field or input have the attribute runat="server" or getting the control will be a bit harder as in terms of code.
Was This Post Helpful? 0
  • +
  • -

#4 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1182
  • View blog
  • Posts: 1,677
  • Joined: 24-August 11

Re: Load fields from database

Posted 10 April 2013 - 11:29 AM

To expand on _HAWK_'s answer, you're using ASP.NET, so utilize the tools of the libraries rather than reinventing the wheel. Wire up a SQLDataSource to a GridView, and set AutoGenerateEditButton="true". Here's the MSDN documentation for GridView, and here's a good tutorial on what you're trying to do (and a whole bunch of other goodies).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1