6
Answers

dropdownlist

Vivek Joy

Vivek Joy

9y
368
1
Hi
 
 
Can Anyone help me...
 
1.I need to display the companyname from the database to the dropdown list.How can i do it?
 
2.Next is by selecting an item in the dropdownlist that item details should be displayed there in different textboxex,etc.
 
 
 
Answers (6)
2
Rajeesh Menoth

Rajeesh Menoth

NA 24.7k 629.3k 9y
Hi,
 
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        TextBox1.Text = DropDownList1.SelectedItem.Value;
    }
 
Ref : click here 
2
Rojalin Sahoo

Rojalin Sahoo

NA 475 26k 9y
1. So bind your dropdownlist with the datatable fetching company name from database BindDropdownlist
 
2. Then fire OnSelectedIndexChanged event of the dropdownlist. 
 
1
Rajeesh Menoth

Rajeesh Menoth

NA 24.7k 629.3k 9y
Hi,
 
code :
 
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindContrydropdown();
}
}
/// <summary>
/// Bind COuntrydropdown
/// </summary>
protected void BindContrydropdown()
{
//conenction path for database
using (SqlConnection con = new SqlConnection("Data Source=SureshDasari;Integrated Security=true;Initial Catalog=MySampleDB"))
{
con.Open();
SqlCommand cmd = new SqlCommand("Select UserId,UserName FROM UserInformation", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
ddlCountry.DataSource = ds;
ddlCountry.DataTextField = "UserName";
ddlCountry.DataValueField = "UserId";
ddlCountry.DataBind();
ddlCountry.Items.Insert(0, new ListItem("--Select--", "0"));
con.Close();
}
}
 
initialize dropdown selected value to  textbox..
 
Ref : click here 
0
Vivek Joy

Vivek Joy

NA 137 11.1k 9y
hi sir
i will show my form
 
 
in this form while selecting an item in dropdown list the details of that items should be displayed. 
0
Vivek Joy

Vivek Joy

NA 137 11.1k 9y
thanks but i need to populate the values to textboxes according to the selection of item in dropdownlist
0
Vivek Joy

Vivek Joy

NA 137 11.1k 9y
thanks but i need to populate the values to textboxes according to the selection of item in dropdownlist