protected void ddldropdownlist1_SelectedIndexChanged(object sender, EventArgs e)
{
GetData(ddldropdownlist1.SelectedItem.Value);
}
Hello vinz
Can you please tell me where to initialise ddldropdownlist1. Is it converting the fields in the column into the dropdown. If it is so, where to initialise it.
below is my code:
.aspx :
<asp:TextBox ID="txtVendorID" MaxLength="100" runat="server" SkinID="TextBox" ></asp:TextBox>
.cs :
private void GetData(string vendorID)
{
DataTable dt = new DataTable();
using (SqlConnection Connection = new SqlConnection(@"Data Source=.;Initial Catalog=VendorDatabaseAdministration;User Id=ADMIN;pwd=0000"))
{
Connection.Open();
SqlCommand sqlCmd = new SqlCommand("SELECT * FROM VendorGeneralDescription WHERE [Vendor ID]= @VendorID", Connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlCmd.Parameters.AddWithValue("@VendorID", txtVendorID.Text);
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
txtVendorID.Text = dt.Rows[0]["[Vendor ID]"].ToString(); //Where ColumnName is the Field from the DB that you want to display
}
Connection.Close();
}
}
protected void ddldropdownlist1_SelectedIndexChanged(object sender, EventArgs e)
{
GetData(ddldropdownlist1.SelectedItem.Value);
}