zezu10 Posted December 14, 2006 Share Posted December 14, 2006 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 More sharing options...
aspnetguy Posted December 14, 2006 Share Posted December 14, 2006 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 thisPrivate 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 More sharing options...
zezu10 Posted December 14, 2006 Author Share Posted December 14, 2006 thank you very much mate, seems I had it in the wrong place.cheers again. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now