Ask a Question related to ASP.NET General, Design and Development.
-
huobazi #1
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> <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
-
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... -
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... -
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... -
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... -
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... -
huobazi #2
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...event> 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...> a.ascx> > 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> > in my aspx,
> > but the DDL BigClassList can not Post Back and Can not do thehave> > "BigClassList_SelectedIndexChanged" so the second DDL SmallClassListOnSelectedIndexChanged="BigClassList_SelectedIndex Changed"></asp:dropdownlis> no>> > items
> > *************************
> > some ascx code:
> >
> > "><asp:dropdownlist ID="BigClassList" Width="100" Height="18"
> > AutoPostBack="True" runat="server"
> >>> > t> <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



Reply With Quote

