reuse gridview after changing data datasource parameters

Discussion in 'ASP .Net' started by Greg Ramsey, Mar 19, 2006.

  1. Greg Ramsey

    Greg Ramsey Guest

    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
     
    Greg Ramsey, Mar 19, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    5
    Views:
    549
    Steve C. Orr [MVP, MCSD]
    May 17, 2005
  2. Hylander

    To reuse or not to reuse....

    Hylander, Feb 26, 2004, in forum: Java
    Replies:
    0
    Views:
    427
    Hylander
    Feb 26, 2004
  3. Amil Hanish
    Replies:
    0
    Views:
    365
    Amil Hanish
    Aug 21, 2006
  4. code reuse and design reuse

    , Feb 7, 2006, in forum: C Programming
    Replies:
    16
    Views:
    1,040
    Malcolm
    Feb 12, 2006
  5. jacob navia

    To reuse or not to reuse

    jacob navia, Nov 5, 2006, in forum: C Programming
    Replies:
    19
    Views:
    545
    Dave Thompson
    Dec 18, 2006
Loading...

Share This Page