When we select a table Name in Dropdownlist that table data should be displayed in gridview.
The problem is tha following code is working in WindowsForms but not in Asp.net. I want to do the same thing in Asp.net? What can i do
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
SqlConnection con = new SqlConnection("user id=sa;password=hari;database=emp;server=.");
SqlDataAdapter da;
DataSet ds;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string s = "select * from empdetails";
da = new SqlDataAdapter(s, con);
ds=new DataSet();
da.Fill(ds,"empdetails");
string s1 = "select * from std";
da = new SqlDataAdapter(s1, con);
da.Fill(ds, "std");
cmbTable.Items.Add("empdetails");
cmbTable.Items.Add("std");
}
private void cmbTable_SelectedIndexChanged(object sender, EventArgs e)
{
DGVSample.DataSource = ds;
DGVSample.DataMember = cmbTable.SelectedItem.ToString();
}
}
}
Sra1