dataset
How to fill dataset from dropdownlist?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Master BillaPosted Sep 10, 2009, 5:47 AM
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