The Question is the programmer has to design a page as shown below.
Before the web page is loaded the programmer has to load all the table names from Database(he specifies in web.config file). the user can select any item from the dropdown list then the selected item( table name).then we need to display entire details in that table using gridview.

Krishna GaradRank #191 · 12.8K reputationPosted Jan 18, 2012, 12:19 AM EST
Page_Load
{
SqlConnection Cn=new SqlConnection("ConnectionstringHere");
SqlCommand cmd=new SqlCommand("
SELECT * FROM sys.Tables",cn);SqlDataAdapter da=new SqlDataAdapter(cmd);
DataSet ds=new DataSet();
da.Fill(ds);
DropDownList1.DataSource=ds.Tables[0];
DropDownList1.DataTextField="name";
DropDownList1.DataValueField="name";
DropDownList1.DataBind();
}
and in dropdownlist selected index changed event you can select records from the selected table in dropdownlist.
Datta KharadRank #2,135 · 668 reputationPosted Jan 17, 2012, 10:49 PM EST
Programmer has to design a page as user can select any item from the dropdown list then the selected item table is to shown to user.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 17, 2012, 10:54 PM EST
from your blog i not getting you. canu please provide more details.
Naga Kota17 reputationPosted Jan 17, 2012, 10:56 PM EST
Naga Kota17 reputationPosted Jan 17, 2012, 11:01 PM EST
the list items in drop down list is the names of tables available in database(given by user).There we need to bind the dropdown list.
when user selects a list item from drop down list then we need to entire data of that particular table.
can i know how to bind the dropdown list by writing code.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 18, 2012, 12:08 AM EST
you may retreive your table name from avalable in DB. here queryfor this.
select * from sys.objects s where type='U'
and how to create connection
using System.Data.SqlClient;
SqlConnection myConnection = new SqlConnection("user id=username;password=password;server=serverurl;Trusted_Connection=yes;database=database; connection timeout=30");
myConnection.Open();
DataSet dset = new DataSet();
SqlDataAdapter adp = new SqlDataAdapter("select * from sys.objects s where type='U'", myConnection);
adp.Fill(dset);
ComboBox1.DataSource = dset.Tables(00;
ComboBox1.DisplayMember = "Name";
myConnection.Close()
hope this help.
Naga Kota17 reputationPosted Jan 18, 2012, 1:32 AM EST
can u tell
=>how can i retrieve entire data into grid view of selected list item.
Krishna GaradRank #191 · 12.8K reputationPosted Jan 18, 2012, 2:09 AM EST
DropDownList1_SelectedIndexChanged
{
SqlConnection Cn=new SqlConnection("ConnectionstringHere");
SqlCommand cmd=new SqlCommand("
SELECT * FROM "+DropDownList1.SelectedValue.ToString(),cn);SqlDataAdapter da=new SqlDataAdapter(cmd);
DataSet ds=new DataSet();
da.Fill(ds);
GridView1.DataSource=ds.Tables[0];
GridView1.DataBind();
}
Naga Kota17 reputationPosted Jan 22, 2012, 9:10 PM EST