Thursday, 1 May 2014

Binding table name in dropdownlist and shoing data in gridview based on different table

No comments
First bind table name in dropdownlist , than on button click event


 protected void Button1_Click(object sender, EventArgs e)
    {
        var scon = "your connectionstring";
        var cmd = "select * from " + DropDownList1.SelectedValue;

        var dt = new DataTable();
        var da1 = new SqlDataAdapter(cmd, scon);
        da1.Fill(dt);

        GridView1.DataSource = dt;
        GridView1.DataBind();               
    }