Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 29th, 2008, 11:21 AM
Registered User
 
Join Date: Oct 2007
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

 
Old February 18th, 2008, 11:13 AM
Registered User
 
Join Date: Jan 2008
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







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 [email protected] 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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.