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. Advertising

  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~~


    "mike C." <> дÈëÏûÏ¢ÐÂÎÅ
    :...
    > Why don't you put a break point at BigClassList_SelectedIndexChanged() to
    > see if program goes there.
    >
    >
    > "huobazi" <> wrote in message
    > news:O$...
    > > 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
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marina
    Replies:
    0
    Views:
    950
    Marina
    Aug 12, 2003
  2. =?Utf-8?B?SklNLkgu?=

    populate ddl from two tables

    =?Utf-8?B?SklNLkgu?=, Jun 6, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    410
    Eliyahu Goldin
    Jun 6, 2005
  3. Laura Grahame via .NET 247

    Two ddl's in different web grid cells

    Laura Grahame via .NET 247, Sep 20, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    146
    Laura Grahame via .NET 247
    Sep 20, 2004
  4. mharness

    can't remove listitem from ddl in loop

    mharness, Dec 12, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    130
    mharness
    Dec 12, 2006
  5. Mike D

    Using AutoPostBack with two Textboxes

    Mike D, Dec 12, 2008, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    108
    Mike D
    Dec 12, 2008
Loading...

Share This Page