Can NOt AutoPostBack for two DDL

Discussion in 'ASP .Net' started by huobazi, Jul 2, 2003.

  1. huobazi

    huobazi Guest

    Can NOt AutoPostBack for two DDL
    Posted: 07-03-2003 01:35 AM
    I have a usercontrol a.ascx ,put two DDL on the ascx.
    in an aspx's codebehind Page_Load i use LoadControl to Load the a.ascx
    in my aspx,
    but the DDL BigClassList can not Post Back and Can not do the event
    "BigClassList_SelectedIndexChanged" so the second DDL SmallClassList have no
    items
    *************************
    some ascx code:

    "><asp:dropdownlist ID="BigClassList" Width="100" Height="18"
    AutoPostBack="True" runat="server"
    OnSelectedIndexChanged="BigClassList_SelectedIndexChanged"></asp:dropdownlis
    t> &nbsp;&nbsp; <asp:dropdownlist ID="SmallClassList" Width="100"
    runat="server"></asp:dropdownlist>
    *************************
    some ascx's codebehind codes


    public void Page_Load(Object sender,EventArgs e)

    {

    if(!IsPostBack)

    {

    BigClassDropDownListInit();

    SmallClassDropDownListInit();

    }

    }

    public void BigClassDropDownListInit()

    {

    Conn.Open();

    OleDbCommand commBigClass=new OleDbCommand("select
    BigClassName,ID from RootClass order by ID",Conn);

    OleDbDataReader MyReaderBigClass1=commBigClass.ExecuteReader();

    BigClassList.DataSource=MyReaderBigClass1;

    BigClassList.DataTextField="BigClassName";

    BigClassList.DataValueField="ID";

    BigClassList.DataBind();

    BigClassList.SelectedIndex = 0;

    MyReaderBigClass1.Close();

    Conn.Close();

    }

    public void BigClassList_SelectedIndexChanged(Object sender,EventArgs e)

    {

    SmallClassDropDownListInit();

    }

    public void SmallClassDropDownListInit()

    {

    Conn.Open();

    string strCom="select TypeName,ID from Type ";

    strCom+=" Where BigClassName ='"+BigClassList.SelectedItem.Text+"' ";

    strCom+=" order by ID";

    OleDbCommand commSmallClass=new OleDbCommand(strCom,Conn);

    OleDbDataReader
    MyReaderSmallClass1=commSmallClass.ExecuteReader();

    SmallClassList.DataSource=MyReaderSmallClass1;

    SmallClassList.DataTextField="TypeName";

    SmallClassList.DataValueField="ID";

    SmallClassList.DataBind();

    SmallClassList.SelectedIndex = 0;

    MyReaderSmallClass1.Close();

    Conn.Close();

    }
     
    huobazi, Jul 2, 2003
    #1
    1. Advertisements

  2. huobazi

    huobazi Guest

    a uscontrol test.ascx have a dropdownlist web control the dropdownlist's
    AutoPostBack property is set "true"
    but when i use Loadcontrol("test.ascx") in a aspx fiel's Page_Load event the
    dropdownlist which in the ascx can not run good it can not autopostback and
    can not call the OnselectedChange event. help me pls~~
     
    huobazi, Jul 2, 2003
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.