DropDown/ListBox databound with correct value on a

Results 1 to 2 of 2

Thread: DropDown/ListBox databound with correct value on a

  1. #1
    Join Date
    Dec 1969

    Default DropDown/ListBox databound with correct value on a

    Hey - I was wondering if anyone could help me with a problem with listbox/dropdowns that I am having... Any assistance would be greatly appreciated. I have a form that is populated from a SQL command. Let&#039;s say the form is a basic address form (actually it&#039;s inventory but an address form make is easier to understand). Anyway, there are several fields - name, address, city, state and Zip - with State being a DropDownList. OK, Currently State is populated with your typical info (AL, AK, MS, OH, TN, NY....) but my problem is when that form is populated from the SQL command, I want the state ddl&#039;s selectedIndex to reflect the current value in the database and not the top of the list.<BR><BR>Here is something I was trying (and it was not working worth a flip but it might give a good idea):<BR><BR><BR> Private Sub btnRetrieve_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRetrieve.Click<BR> SQLDA_Select_product.SelectCommand.Parameters("@hc number").Value = ddlHCNumber.SelectedItem.Value<BR> fldName.DataBind()<BR> fldAddress.DataBind()<BR> fldCity.DataBind()<BR> fldZip.DataBind()<BR> fldPhone.DataBind()<BR> lblState.databind()<BR><BR> Dim myDropDown As System.Web.UI.WebControls.DropDownList = Page.FindControl("ddlState")<BR> Dim curState As System.Web.UI.WebControls.Label = Page.FindControl("lblState")<BR><BR> myDropDown.SelectedIndex = myDropDown.Items.IndexOf(myDropDown.Items.FindByTe xt(curState.Text))<BR><BR> End Sub<BR><BR>I know this is probably easy but I am at a total loss. Should I setup a separate function to handle this or can it be all worked in this way? And then how to rebind that dropDown. I think I&#039;ve gone brain dead on this one....

  2. #2
    Join Date
    Dec 1969

    Default RE: DropDown/ListBox databound with correct value

    Sorry I can&#039;t help you but I came here to post the same exact thing so lets hope someone knows.

Posting Permissions

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