Can NOt AutoPostBack for two DDL

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Can NOt AutoPostBack for two DDL

    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_SelectedIndex Changed"></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 Guest

  2. Similar Questions and Discussions

    1. TabIndex and AutoPostBack
      I have a long form that includes several fields which require AutoPostBack=True. I want the user to be able to tab through the fields in sequence...
    2. no AutoPostBack for Grid?
      I have a grid with a select button. I went to turn off AutoPostBack and there is no such attribute. Is there any way to make a grid behave as...
    3. Problem with Autopostback
      I have a relatively long page with a number of webcontrols with "autopostback" set to true. The contents/items/datasources of the subsequent...
    4. AutoPostBack
      I have another question. On my page there is a datagrid and in a templatecolumn it contains a dropdownlist. The AutoPostBack property of the...
    5. AutoPostBack question.
      Hi, I'm having a straight HTML <input type="text" onkeypress="CheckKey();"> within a <form runat="server">. When I press ENTER when in the...
  3. #2

    Default Re: Can NOt AutoPostBack for two DDL

    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." <mike@mike.mike> дÈëÏûÏ¢ÐÂÎÅ
    :uWHN7FMQDHA.2460@TK2MSFTNGP10.phx.gbl...
    > Why don't you put a break point at BigClassList_SelectedIndexChanged() to
    > see if program goes there.
    >
    >
    > "huobazi" <huobazi@Aspxboy.com> wrote in message
    > news:O$vFMvLQDHA.3880@tk2msftngp13.phx.gbl...
    > > 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_SelectedIndex Changed"></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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139