www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Display corresponding details from database when Listbox item is selected

  1. #1
    Join Date
    May 2007
    Posts
    110

    resolved [RESOLVED] Display corresponding details from database when Listbox item is selected

    i'm using VB.NET.

    i have a table names "EMP". this table contain employee details like Index, empID, First name, Last name, address, phone number etc.

    while page loads, i need to display Last name First name of all employees in a listbox. and if i select any employee name from listbox and press "EDIT" button, then i need to display the employee details for that particular employee what we selected in listbox.

    right now what i did is like when an emp is selected in listbox, i will check the last name and first name in database and display details. but if two employees were there having same first name and last name, then error will occurs and the corresponding employees detail won't be displayed. but i need only first name and last name in listbox.

    in that table Index and EMPID were non Dupicated numbers. so any way is there to give index for each employee name in listbox and when an employee name is selected, then according to that index search in database and get corresponding employee details.

    if any one have any idea how to do this please let me know. and if you can provide an example then that will be great help for me.

    thanks in advance.

  2. #2
    Join Date
    Jun 2004
    Location
    Kansas City, MO
    Posts
    1,607
    Yes you can do exaclty that.
    The listbox has 2 properties that you can set:
    DataTextField - This is what is displayed
    DataValueField - This is the value that is associated with that item

    So basically set First and Last name in the DataTextField and then set the ID in the DataValueField.

    When you get the value get the value of the DataValueField and not the DataTextField which is what your currently doing.

    Hope that helps.

  3. #3
    Join Date
    May 2007
    Posts
    110
    once again thanks for this help too...

    now i can seperate DataTextField and DataValueField and take corresponding data from table.

    thanks a lot...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles