Combo Box and ASP.net

Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
Reply

Join Date: Aug 2008
Posts: 93
Reputation: Tank50 is an unknown quantity at this point 
Solved Threads: 1
Tank50's Avatar
Tank50 Tank50 is offline Offline
Junior Poster in Training

Combo Box and ASP.net

 
0
  #1
Aug 27th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

Re: Combo Box and ASP.net

 
0
  #2
Aug 27th, 2008
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
If u r query is achieved,mark the thread as solved

Live and Let Live
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 93
Reputation: Tank50 is an unknown quantity at this point 
Solved Threads: 1
Tank50's Avatar
Tank50 Tank50 is offline Offline
Junior Poster in Training

Re: Combo Box and ASP.net

 
0
  #3
Aug 27th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1
Reputation: culeu is an unknown quantity at this point 
Solved Threads: 0
culeu culeu is offline Offline
Newbie Poster

Re: Combo Box and ASP.net

 
0
  #4
Dec 27th, 2008
Add more infor for Form submit.
AutoPostBack="True"

  1. <asp:DropDownList ID="ddl_Select" runat="server" Width="103px" OnSelectedIndexChanged="ddl_Select_SelectedIndexChanged" OnTextChanged="ddl_Select_TextChanged" [B]AutoPostBack="True"[/B]>
  2. </asp:DropDownList>
Last edited by peter_budo; Dec 29th, 2008 at 11:28 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC