reuse gridview after changing data datasource parameters

G

Greg Ramsey

Hi - I'm a real newbie to ASP . . so please forgive me. . . and please point
me in the right direction for how to do this "the right way" . . :)

Using Northwind DB as an example, I have a gridview bound to a
sqldatasource, with a SelectQuery = SELECT [ProductName], [QuantityPerUnit],
[UnitPrice], [UnitsInStock] FROM [Alphabetical list of products]

That all works fine. . . but what I want to do next is this: Users clicks on
button "Customers and Suppliers By City", and the code for the button simply
sets SelectCommand = SELECT * FROM [Customer and Suppliers by city]

This obviously bombs when I click on the button, and it states that
"ProductName" as not found on the selected data source.

I hate to think of creating a separate gridview and datasource for each
Table I desire to display. . . Is there any way I can "reset" the gridview
so that it pulls the proper schema from the "updated" datasource before
rendering in the display? I've tried databind() for both sqldatasource and
gridview.

Any examples you could point me to would be greatly appreciated.

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top