Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Dynamic GridView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pansell@douc.com - 12 Mar 2008 13:48 GMT
Hi,

I have a dropdown list that is populated with table names from my
database using SqlDataSource1. When I change the selected index I can
get the table name back from the dropdown and display it in a label.

What I want to do is display the data from the table selected in the
dropdown in the GridView control but I have no idea how to do it. So
basically everytime the user selects a different table from the
dropdown the data is displayed in the GridView. The columns in each of
the tables could be different.

I used to do this kind of thing all the time in ASP, but can't work
out the way or approach to do this.

I'm using Framework 2.0, VS Express 2008 and SQL Server 2000.

Many Thanks
Paul
Paulus E Kurniawan - 13 Mar 2008 02:18 GMT
Paul,

Set the AutoPostBack property of the DropDownList to True, then handle the
SelectedIndexChanged event. In the event handler method, you can pass in the
selected table name as a parameter to your business logic/data access class,
then bind the returned data to the GridView.

If you are using ObjectDataSource with the GridView, create a
ControlParameter object in your SelectParameters collection:

<SelectParameters>
   <asp:ControlParameter Name="Table" ControlID="DropDownList1"
PropertyName="Text" />
</SelectParameters>

Hope this helps.
Signature

Paulus E Kurniawan
http://www.paulusevan.net

> Hi,
>
[quoted text clipped - 15 lines]
> Many Thanks
> Paul
Paulus E Kurniawan - 13 Mar 2008 02:38 GMT
> <SelectParameters>
>     <asp:ControlParameter Name="Table" ControlID="DropDownList1"
> PropertyName="Text" />
> </SelectParameters>

Specify the type for the ControlParameter to create a strongly typed
parameter:

<SelectParameters>
   <asp:ControlParameter Name="Table" ControlID="DropDownList1"
PropertyName="Text" Type="String" />
</SelectParameters>
Signature

Paulus E Kurniawan
http://www.paulusevan.net

> Paul,
>
[quoted text clipped - 32 lines]
> > Many Thanks
> > Paul

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.