Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm trying to make a order form where once the user selects an item from the drop down list, the label will automatically be populated with the user's selection.
suppose user select item from drop down then label populate rate for that item

give me a sample example..

Thanks
Posted
Comments
Sandeep Mewara 26-Oct-10 1:51am    
Web application or Winforms?
call to .net 26-Oct-10 1:58am    
web application.

1 solution

Ok for that u will have to write code on dropdown selected index changing and
make its autopostback property true;
and write code as
SqlCommand cmd = new SqlCommand("select * from tableme where item=@item ", con);
con.Open();
cmd.Parameters.AddWithValue("@item ", dropdown.selectedvalue );

SqlDataReader dtr = cmd.ExecuteReader();
if (dtr.Read())
{
Label1.Text=dtr["Rate"].Tostring();
dtr.Close();
con.Close();

}
else
{

Label1.Text = "No Price is there";
dtr.Close();
con.Close();

}
 
Share this answer
 
v2
Comments
RDBurmon 26-Oct-10 1:59am    
Hi Mohd Wasif , Can u tell me what is the use of autopostback property true.
Your answer may solve my another question thats why i am asking ?
call to .net 26-Oct-10 2:19am    
Hi, Wasif i am using dropdown inside gridview can i use same for that??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900