private void FillDropDownSQL()
{
SqlConnection conVendor = new SqlConnection("Data Source=AB2\\SQLEXPRESS;Initial Catalog=Tiger;Integrated Security=True");
SqlCommand comVendor = new SqlCommand("SELECT vendor_name,vendor_code FROM vendor", conVendor);
try
{
conVendor.Open();
DropDownList1.Items.Clear();
SqlDataReader drVendor = comVendor.ExecuteReader(CommandBehavior.CloseConnection);
while (drVendor.Read())
{
DropDownList1.Items.Add(drVendor[0].ToString());
}
}
catch (Exception e)
{
Response.Write(e.ToString());//An error has occurred: " &
}
conVendor.Close();
}
when I give the above method in the page load I am able to see the text part of the dropdownlist . But requirement is that I have to add the vendor_code
in the dropdownlist value part .
i.e: in the text = vendor_name and value = vender_code.
So provide me the guidance to add that.