protected void RefList_SelectedIndexChanged(object sender, EventArgs e)
{
// Define ADO.NET objects.
string selectSQL;
selectSQL = "SELECT * FROM Project ";
selectSQL += "WHERE Ref#= '"+RefList.SelectedItem.Text +"'";
// Label14.Text = RefList.SelectedItem.Text;
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.;Initial Catalog=Project;User ID=sa;Password=786";
SqlCommand cmd = new SqlCommand(selectSQL, con);
SqlDataReader reader;
// Try to open database and read information.
try
{
con.Open();
reader = cmd.ExecuteReader();
reader.Read();
TextBox1.Text = reader["Description"].ToString();
TextBox2.Text = reader["Purchase_Price"].ToString();
TextBox3.Text = reader["Sale_Price"].ToString();
TextBox4.Text = reader["Quantity"].ToString();
TextBox5.Text = reader["Warning_Quantity"].ToString();
TextBox6.Text = reader["Expiry_Date"].ToString();
TextBox7.Text = reader["Vendors"].ToString();
TextBox8.Text = reader["Ref#"].ToString();
/* TextBox1.Text = reader["0"].ToString();
TextBox2.Text = reader["1"].ToString();
TextBox3.Text = reader["2"].ToString();
TextBox4.Text = reader["3"].ToString();
TextBox5.Text = reader["4"].ToString();
TextBox6.Text = reader["5"].ToString();
TextBox7.Text = reader["6"].ToString();
TextBox8.Text = reader["7"].ToString(); */
reader.Close();
lblStatus.Text = "";
}
catch (Exception err)
{
lblStatus.Text = "Error in displaying data. ";
lblStatus.Text += err.Message;
}
finally
{
con.Close();
}
}
Mona Ali 0 Light Poster
thines01 401 Postaholic Team Colleague Featured Poster
thines01 401 Postaholic Team Colleague Featured Poster
thines01 401 Postaholic Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.