Results 1 to 5 of 5

Thread: Binding text boxes

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    159

    Binding text boxes

    HEY

    Im just wondering how do u bind information from a database to textboxes using code

    i have the following fields in a database called ROOM stored in a MS Access File called Hotel.mdb

    roomID
    RoomNumber
    Description

    so in other words bind the following

    roomID = TextBox1.text
    roomNumber = TextBox2.text
    Description = TextBox2.text

    then i would like to navigate the fields using a button to goto a previouse entry in the database and to goto the next entry in the database

    im not sure how to do it please help

    thanks

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    I have had problems with binding to a text box also. The only way I have done it so far is to use a datareader.


    Things I do when I am bored: DotNetable

  3. #3
    New Member
    Join Date
    Mar 2004
    Posts
    3

    Thumbs up Binding TextBox

    Hiiiiii ....

    you can binding textbox by this code:

    me.textbox.datasource=dataset
    me.textbox.datamember="tabel name"
    me.textbox.datavaluefield="col name to be sorting with"
    me.textbox.datatextfield="col name which we need to displsy"
    sqldataadapter.fill(dataset)
    me.textbos.databind

  4. #4
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    So what you want is to navigate through records, displaying 1 record on screen at a time?

    I'd say the easiest way is to retrieve the data from the database into a array,datatable or SQLDataAdapter.

    then have some code behind a button like
    VB Code:
    1. sub Next_click(ByVal s as object,ByVal e as eventargs)
    2.     indexcount += 1
    3.     if indexcount <= dt.rows.count
    4.         ' dt is a datatable
    5.         textbox1.text = dt.Rows(indexcount).Item(0)
    6.         textbox2.text = dt.Rows(indexcount).Item(1)
    7.         textbox3.text = dt.Rows(indexcount).Item(2)
    8.     else
    9.         'end of data reached
    10.     end if
    11. end sub

  5. #5
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    Ahhhh!!!

    Now i see


    Things I do when I am bored: DotNetable

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width