Web Design and Development Forums

Binding Textboxes

This is a discussion on "Binding Textboxes" within the ASP.NET Forum section. This forum, and the thread "Binding Textboxes are both part of the Program Your Website category.

Old Jan 29th, 2008, 14:24   #1 (permalink)
New Member
 
Join Date: Sep 2007
Location: London
Age: 28
Posts: 4
Binding Textboxes

Hi
I have a web form with a few textboxes, ie Ref number, requestor, service area and I'd like to bind those textboxes to the relevant columns in the Sql db but I'm not sure how. The idea is that a user can search the db by entering their ref number and their request is displayed via the textboxes. They can then edit their request and re-submit it. I'm using textboxes rather than a details view or gridview so we have more flexibility over the design.
How do I go about doing this? Any help/code samples would be great, I'm using (or trying to use ) C#.
thanks
RubyRue is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Feb 19th, 2008, 22:20   #2 (permalink)
Junior Member
 
Join Date: Feb 2008
Location: Paris
Age: 31
Posts: 18
Re: Binding Textboxes

The best way to do tis is to get your data in the C# code behind and add it to your component.
ie, you can write things like (for a TextBox):
string myData = MyDao.getMyData();
myTextBoxComponent.Text = myData;

Does it help you ?

MagicBen
magicben is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Feb 21st, 2008, 17:51   #3 (permalink)
New Member
 
Join Date: Feb 2006
Location: Norwich, UK
Posts: 6
Re: Binding Textboxes

Hi,

I would use the SqlDataReader object....

I don't know C# but hopefully you'll be able to see what's going on in this VB example to be able to do it in C# (btw, this is assuming you're only returning one record each time).

Code: Select all
'Build connection string using the ConnectionStrings property in web.config
Dim con as New SqlConnection(ConfigurationManager.ConnectionStrings("PropertyNameHere").ConnectionString)

'Create Command Object
Dim cmd as New SqlCommand("Select * from DBTableName", con)

'Open Connection
con.Open

'Create SQLDataReader
Dim reader as SqlDataReader = cmd.ExecuteReader

'Code inside IF shows how you can use column name or column ordinal (position) which is zero based
If reader.Read Then
   textbox1.text = reader("ColumnNamefromDatabase")
   textbox2.text = reader.GetString(2)
Else
   'No Data Returned
End If

reader.Close
con.Close
Hope this helps.
kato77 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using listeners with dynamic textBoxes DrGonzo Flash & Multimedia Forum 0 Aug 8th, 2007 10:24
writing a function to verify data inputted in textboxes jayaime JavaScript Forum 2 Jul 4th, 2006 03:29
Lists, Buttons and Textboxes callamac HTML Forum 4 Apr 6th, 2006 13:39
autofill textboxes hamboy HTML Forum 3 Feb 14th, 2006 19:42
[SOLVED] I need help with data binding Anonymous User JavaScript Forum 1 Mar 16th, 2005 16:04



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 21:33.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59