Datta Kharad
posted
225 posts
since
Nov 21, 2010
from
Mumbai
|
|
Re: ASP.NET
|
|
|
|
|
|
|
|
|
|
|
Hi 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.
|
|
|
|
|
Please mark as Accepted answer if your query resolved.
Thanks & Regards Datta S. Kharad
|
|
|
|
|
|
Jignesh Trivedi
posted
501 posts
since
Dec 26, 2011
from
India
|
|
Re: ASP.NET
|
|
|
|
|
|
|
|
|
|
|
hi,
from your blog i not getting you. canu please provide more details.
|
|
|
|
|
|
knv satyanarayana
posted
9 posts
since
Sep 21, 2011
from
|
|
Re: ASP.NET
|
|
|
|
|
|
|
|
|
|
|
how can i connect to database and find the table names so that they can they can be used list items for drop down list .
|
|
|
|
|
|
knv satyanarayana
posted
9 posts
since
Sep 21, 2011
from
|
|
Re: ASP.NET
|
|
|
|
|
|
|
|
|
|
|
first we need to design a dropdown list 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 Trivedi
posted
501 posts
since
Dec 26, 2011
from
India
|
|
Re: ASP.NET
|
|
|
|
|
|
|
|
|
|
hi,
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.
|
|
|
|
|
|
Krishna Garad
posted
825 posts
since
Dec 19, 2009
from
Hyderabad
|
|
Re: ASP.NET
|
|
|
|
|
|
|
|
|
|
|
you can try this in page_load event
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.
|
|
|
|
|
Mark as "This Is Correct Answer" if helps you.
|
|
|
|
|
|
knv satyanarayana
posted
9 posts
since
Sep 21, 2011
from
|
|
Re: ASP.NET
|
|
|
|
|
|
|
|
|
|
|
after binding into drop down list. can u tell =>how can i retrieve entire data into grid view of selected list item.
|
|
|
|
|
|
Krishna Garad
posted
825 posts
since
Dec 19, 2009
from
Hyderabad
|
|
Re: ASP.NET
|
|
|
|
|
|
|
|
|
|
|
In dorpdownlist_selectedIndexChanged event write this code 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(); }
|
|
|
|
|
Mark as "This Is Correct Answer" if helps you.
|
|
|
|
|
|
knv satyanarayana
posted
9 posts
since
Sep 21, 2011
from
|
|
Re: ASP.NET
|
|
|
|
|
|
|
|
|
|
|
THE Final Code is being attached
|
|
|
|
|
|