Control contents disappear after postback

  • Follow


I have a VB2008 website with, among others, 3 dropdownlists.  Two of
these are autopostback and unbound, ddlFuel1a and ddlFormulation1.
Whenever I click on any autopostback  control, the entire content of
both of these controls is deleted. Other than the Imports and Inherits
lines, the following is the entirety of my VB code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            ddlFuel1a.Items.Add("Gasoline")
            ddlFuel1a.Items.Add("Diesel")
            ddlFormulation1.Items.Add("All Formulations")
            ddlFormulation1.Items.Add("Conventional")
            ddlFormulation1.Items.Add("Reformulated")
        End If
    End Sub

    Protected Sub ddlFuel1_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
ddlFuel1a.SelectedIndexChanged
        ddlGrade1.Items.Clear()          ' Not autopostback
        ddlFormulation1.Items.Clear()

        If ddlFuel1a.SelectedIndex = 0 Then ' Gasoline
            ddlGrade1.Items.Add("All Grades")
            ddlGrade1.Items.Add("Regular")
            ddlGrade1.Items.Add("Mid Grade")
            ddlGrade1.Items.Add("Premium")
            ddlGrade1.Text = "All Grades"
            ddlFormulation1.Items.Add("All Formulations")
            ddlFormulation1.Items.Add("Conventional")
            ddlFormulation1.Items.Add("Reformulated")
            ddlFormulation1.Text = "All Formulations"
        Else
            ddlGrade1.Items.Add("No 2 Diesel")
            ddlGrade1.Text = "No 2 Diesel"
            ddlFormulation1.Items.Add("All Formulations")
            ddlFormulation1.Items.Add("Low Sulfur (15-500ppm)")
            ddlFormulation1.Items.Add("Ultra Low Sulfur (0-15ppm)")
            ddlFormulation1.Text = "All Formulations"
        End If

    End Sub

Help would be appreciated!!
0
Reply MWulfe 5/17/2010 10:30:25 PM

On May 18, 12:30=A0am, MWulfe <mwu...@yahoo.com> wrote:
> I have a VB2008 website with, among others, 3 dropdownlists. =A0Two of
> these are autopostback and unbound, ddlFuel1a and ddlFormulation1.
> Whenever I click on any autopostback =A0control, the entire content of
> both of these controls is deleted. Other than the Imports and Inherits
> lines, the following is the entirety of my VB code:

I don't see any error here, it looks correct to me. You said, that
ddlFormulation1 has also autopostback on. Do you have any code (a sub)
for this event? Maybe this is a problem?
0
Reply Alexey 5/25/2010 9:53:21 PM


1 Replies
478 Views

(page loaded in 0.064 seconds)

Similiar Articles:













8/21/2012 7:14:36 AM


Reply: