Jump to content

DropDownList Issue


zezu10
 Share

Recommended Posts

I currently have a DropDownList that I have populated through a StoredProcedure.It populates ok, however, when I seleted an item down the list, it always returns the one at the top?Could anyone give me any idea of what may be causing this?

	Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load		'Put user code to initialize the page here		FillDealerDDL()	End Sub	Sub FillDealerDDL()		Dim GetReader As New GeneralReaderQuery(Constants.LiveGVP, "GetVehiclesFillDDL1")		Me.ddlDealerName.DataSource = GetReader.FetchReader		Me.ddlDealerName.DataTextField = "DealerName"		Me.ddlDealerName.DataValueField = "DealerName"		Me.ddlDealerName.DataBind()	End Sub

Link to comment
Share on other sites

I currently have a DropDownList that I have populated through a StoredProcedure.It populates ok, however, when I seleted an item down the list, it always returns the one at the top?Could anyone give me any idea of what may be causing this?
	Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load		'Put user code to initialize the page here		FillDealerDDL()	End Sub	Sub FillDealerDDL()		Dim GetReader As New GeneralReaderQuery(Constants.LiveGVP, "GetVehiclesFillDDL1")		Me.ddlDealerName.DataSource = GetReader.FetchReader		Me.ddlDealerName.DataTextField = "DealerName"		Me.ddlDealerName.DataValueField = "DealerName"		Me.ddlDealerName.DataBind()	End Sub

It is because you are filling the DDL on page_load. When you select an option I assume you have it set to autopostback, this reloads the DDL and selects item 1.Change your code to reflect this
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load		If Not IsPostBack Then			 'Put user code to initialize the page here			 FillDealerDDL()		End If	End Sub

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...