Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
| 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 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
  #1 (permalink)  
Old December 7th, 2005, 11:44 AM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Populating web form with drop down list selection

Okay, I'm really new to this and am not sure how to get this to work, so here goes. I have a web form, User Administration. It contains a "search" button, which allows the user to search by first name or last name or both when clicked, depending on what the user has entered...it then populates the form with first name, last name, location, hardware & software for everyone that falls within the criteria. I've included the code below; however, I also have a databound location list box, which holds 42 of our stores. I can't figure out how to get a list of users at a specific location, if the location (no first or last name) is the only selected item prior to hitting the "search" button...I hope this makes sense and thanks in advance for any help you can give me.

 Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Fname = Trim(txtFnameAdd.Text)
        Lname = Trim(txtLnameAdd.Text)

        sql = "SELECT key_id, Fname, Lname, location, LEFT(Datemodified,11) as DateModified,"
        sql = sql & "'<a href='"
        sql = sql + "'Inventory Assign Hardware.aspx?ID='"
        sql = sql & " + Cast(key_ID as Char) + "
        sql = sql & "'''>Hardware Permissions"
        sql = sql & "</a>' as Hardware,"
        sql = sql & "'<a href='"
        sql = sql + "'Inventory Assign Software.aspx?ID='"
        sql = sql & " + Cast(key_ID as Char) + "
        sql = sql & "'''>Software Permissions"
        sql = sql & "</a>' as Software from Users "

        If txtFnameAdd.Text <> "" And txtLnameAdd.Text = "" Then sql = sql & " WHERE Fname like '%' + '" & Fname & "' + '%'"
        If txtLnameAdd.Text <> "" And txtFnameAdd.Text = "" Then sql = sql & " WHERE Lname like '%' + '" & Lname & "' + '%'"
        sql = sql & BuildQuery()
        daUsers = New System.Data.SqlClient.SqlDataAdapter(sql, SORCInventory)
        daUsers.Fill(dsUser)
        dgUsers.DataSource = dsUser
        dgUsers.DataBind()
    End Sub

    Function GetLocations() As DataSet

        Dim ddlDataSet As DataSet = New DataSet
        Const strSQLDDL As String = _
             "SELECT location FROM location ORDER BY location"

        Dim myDataAdapter As SqlDataAdapter = New _
                              SqlDataAdapter(strSQLDDL, SORCInventory)

        myDataAdapter.Fill(ddlDataSet, "Location")

        Return ddlDataSet
    End Function



Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating a drop down list from an ArrayList snejsnej ASP.NET 1.0 and 1.1 Basics 1 April 20th, 2006 11:14 AM
Java script function on drop down list selection Sachin3k Javascript How-To 3 April 30th, 2005 11:30 AM
populating a drop down with a file list cjcd ASP.NET 1.0 and 1.1 Professional 2 April 18th, 2004 10:37 AM
populating a drop down with a file list cjcd BOOK: Beginning ASP.NET 1.0 1 April 17th, 2004 02:53 AM





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