DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   Combo Box and ASP.net (http://www.daniweb.com/forums/thread142521.html)

Tank50 Aug 27th, 2008 2:34 am
Combo Box and ASP.net
 
Hi

I have dropdown list in my asp.net page.I wrote a below coing coidng in the SelectedIndexChanged,


protected void cmb_Se_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con=new SqlConnection("Data Source=20.1.2.58;Initial Catalog=Customer;User ID=test123");
string str = "select ExecutiveName from Executive where TeCode='"+cmb_Te.Text+"'";
con.Open();
SqlCommand command=new SqlCommand(str,con);
SqlDataAdapter adpter=new SqlDataAdapter(command);
DataSet data=new DataSet();
adpter.Fill(data);
int i= data.Tables[0].Rows.Count;
for (int x = 0; i < i; i++)
{

cmb_Se.Items.Add(data.Tables[0].Rows[x].ToString());

}
}



I mention what is code i wrote in my page,But once i select the text from cmb_Te combo box,the below combo box in not change.Pls give me a answer.

Thank you

greeny_1984 Aug 27th, 2008 3:03 am
Re: Combo Box and ASP.net
 
hi,
u are writing the code in selectchanged event of second combobox as i understand from u r query,so write the code in select changed event of first combobox

Tank50 Aug 27th, 2008 1:30 pm
Re: Combo Box and ASP.net
 
HI

Thanks grenny_1984 for ur reply yes i am was wrong .I have to put that in first combo box,then I select post_back(this is wrong property name ,I could not remember name of the property).But now it works

Thanks
Tank 50

culeu Dec 27th, 2008 5:28 pm
Re: Combo Box and ASP.net
 
Add more infor for Form submit.
AutoPostBack="True"

<asp:DropDownList ID="ddl_Select" runat="server" Width="103px" OnSelectedIndexChanged="ddl_Select_SelectedIndexChanged" OnTextChanged="ddl_Select_TextChanged" [B]AutoPostBack="True"[/B]>
                    </asp:DropDownList>


All times are GMT -4. The time now is 4:33 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC