Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 29th, 2008, 11:21 AM
Registered User
 
Join Date: Oct 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

  #2 (permalink)  
Old February 18th, 2008, 11:13 AM
Registered User
 
Join Date: Jan 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I posted earlier to no response to the same question so after some trial and error I came up with:
  Dim conPubs As Data.SqlClient.SqlConnection
        Dim SQL As String
        Dim MYCompany As String
        conPubs = New Data.SqlClient.SqlConnection("Server=xxx.xxx.xx.xx ;uid=;pwd=;database=DB")
        conPubs.Open()
        MYCompany = BillDropDown.Text

        SQL = "SELECT Name,City,Address1,Address2,State,Country,Postal_C ode,Phone_Num FROM [CUSTOMER] where NAME = '" & MYCompany & " 'Group By Name,City,Address1,Address2,State,Country,Postal_C ode,Phone_Num"
        Dim cmdSelectPeople As Data.SqlClient.SqlCommand
        Dim getpeople As Data.SqlClient.SqlDataReader


        cmdSelectPeople = New Data.SqlClient.SqlCommand(SQL, conPubs)
        getpeople = cmdSelectPeople.ExecuteReader()



        If (getpeople.HasRows) Then

            While (getpeople.Read())
                txtbillname.Text = getpeople("Name").ToString()
                txtcity.Text = getpeople("CITY").ToString()
                txtaddress.Text = getpeople("Address1").ToString()
                txtaddress2.Text = getpeople("Address2").ToString()
                txtState.Text = getpeople("State").ToString()
                txtcountry.Text = getpeople("Country").ToString()
                txtzip.Text = getpeople("Postal_Code").ToString()
                txtbillphone.Text = getpeople("Phone_Num").ToString()
            End While


        End If





        getpeople.Close()
        conPubs.Close()

Being very new to asp and dot net in general…it may not be the best but it works for me. It’s written in VB but sould give some pointers for C.

HTH
Marty


 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Format textboxes dhoward Javascript How-To 1 December 29th, 2006 01:37 AM
binding textboxes to selected radio button abhi_loveu2002 ASP.NET 2.0 Basics 0 December 20th, 2006 05:54 AM
Two TextBoxes hunzian78@yahoo.com ASP.NET 1.0 and 1.1 Basics 5 April 1st, 2006 06:32 AM
From listbox to 5 textboxes ThomasF VB Databases Basics 1 September 23rd, 2004 05:39 PM



All times are GMT -4. The time now is 04:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.