Dataset
How to fill dataset from dropdownlist?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Master BillaRank #2,229 · 630 reputationPosted Sep 10, 2009, 1:47 AM EDT
You can do , like this way
DataSet data = null;
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string slectedValue = comboBox1.SelectedItem.ToString();
using (SqlConnection con = new SqlConnection("connection"))
{
using (SqlCommand cmd = con.CreateCommand())
{
cmd.CommandText = "select * from tableName where ID='" + slectedValue + "'";
cmd.CommandType = CommandType.Text;
data = new DataSet();
using (SqlDataAdapter adapter=new SqlDataAdapter(cmd))
{
adapter.Fill(data);
}
}
}
DataGrid1.DataSource = data.Tables[0];
}
Thank you