Click here to Skip to main content
15,905,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have tired this but its not working its showing me 1st value only
C#
//function i used for this
private void BindView()
{
    SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString);
    con.Open();
    using (SqlCommand command = con.CreateCommand())
    {
        int productid = Convert.ToInt32(ddproduct.SelectedValue.ToString());
        string query = "SELECT productprice FROM Product_Master WHERE is_activate=1 AND productid=" + productid.ToString();
        command.CommandText = query;
            
        SqlDataReader dr = command.ExecuteReader();
        if (dr.Read())
        {
            txtpayment.Text = dr["productprice"].ToString();
        }
        else
        {

        }
        con.Close();
        dr.Close();
    }
}


//drop down 
protected void ddproduct_SelectedIndexChanged(object sender, EventArgs e)
{
    BindView();
}
Posted
Updated 1-Nov-12 0:47am
v2
Comments
Street Racers 1-Nov-12 2:47am    
try to set the "auto postback" property to true.
sumit kausalye 1-Nov-12 3:26am    
i tried that too but its shows only first value when i click on second item still it shows the 1st value and price of 1st item what should i do sir?

1 solution

you can set text property of textbox on selected index changed event of dropdownlist.
write in this event
textbox1.text=ddl1.selecteditem.text;
hope it will work for you..
 
Share this answer
 

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