Can you help with 2 dropdownlist questions... THAN

Results 1 to 2 of 2

Thread: Can you help with 2 dropdownlist questions... THAN

  1. #1
    Join Date
    Dec 1969

    Default Can you help with 2 dropdownlist questions... THAN

    Hi All<BR>I have a form for updating records. I select the contents of my dropdown from a lookup table in SQL. Works fine, except it just lists the options and does not show the value which is stored in another table. How do I get it to show the value from the record table AND still provide the other options stored in the lookup table? Here is my code which fills the dropdown fine (from LUT_CaseType table) -- just doesn&#039;t show the actual value (from Known table). <BR><BR>connMW = New SqlConnection()<BR> connMW.ConnectionString = ConfigurationSettings.AppSettings("conMW")<BR><BR> connMW.Open()<BR> cmdSelect = New SqlCommand("SELECT CaseTypeID, CaseTypeDesc FROM LUT_CaseType", connMW)<BR> dtrCaseType = cmdSelect.ExecuteReader()<BR><BR> ddlCaseType.DataSource = dtrCaseType<BR> ddlCaseType.DataTextField = "CaseTypeDesc"<BR> ddlCaseType.DataValueField = "CaseTypeID"<BR> ddlCaseType.DataBind()<BR> dtrCaseType.Close()<BR><BR> <BR>Second, I use a lookup table for state with 10 different state boxes on my form. Instead of a datareader like above, I use a dataset so I can call the same ds over and over. Works beautifully in my insert form.. Doesn&#039;t work in my update form (gives me back a list of System.Data.DataRowView<BR><BR> dsState = New DataSet()<BR> daState = New SqlDataAdapter("SELECT StateID, StateName FROM LUT_State", connMW)<BR> daState.Fill(dsState, "LUT_State")<BR><BR> ddlCaseState.DataSource = dsState<BR> ddlCaseType.DataTextField = "StateName"<BR> ddlCaseType.DataValueField = "StateID"<BR> ddlCaseState.DataBind()<BR><BR>Thank you in advance for helping me. I am trying to learn and I hate to bother you... I use Unleashed and its quite helpful but I couldn&#039;t find anything about these, searched the net and read through all the back posts on dropdownlists. <BR>Thank you again... Tracie

  2. #2
    Join Date
    Dec 1969

    Default RE: Can you help with 2 dropdownlist questions...

    You have got to query the other table separatly to obtain the value to set the dropdown to.<BR>Then just assign the value as follows:<BR>Me.dropdownName.SelectedValue = SQLDataReader("SomeColumnFromDB")

Posting Permissions

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