Displaying the default fields from a DataSet, to the GridView

Discussion in 'ASP .Net' started by Paul Aspinall, Nov 29, 2005.

  1. Hi
    I'm binding a DataSet, using the ObjectDataSource control, to a GridView

    I want the GridView to default to the columns returned in the DataSet,
    without having to specifically name them.

    How can I do this in code??

    Thanks
    Paul Aspinall, Nov 29, 2005
    #1
    1. Advertising

  2. AutoGenerateColumns ="true" , e.g.


    <asp:gridview ID="Gridview1" runat="server" DataSourceID="SqlDataSource1"
    AutoGenerateColumns ="true" >
    </asp:gridview>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
    ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT [ProductName], [SupplierID], [CategoryID],
    [UnitsInStock], [UnitPrice], [UnitsOnOrder] FROM [Alphabetical list of
    products]">
    </asp:SqlDataSource>
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Paul Aspinall" wrote:

    > Hi
    > I'm binding a DataSet, using the ObjectDataSource control, to a GridView
    >
    > I want the GridView to default to the columns returned in the DataSet,
    > without having to specifically name them.
    >
    > How can I do this in code??
    >
    > Thanks
    >
    >
    >
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Nov 29, 2005
    #2
    1. Advertising

  3. Hi Philip,

    Thanks for the reply.
    Yes - thats what I was looking for. I actually found it about 5 minutes
    after making the post, but my news server hadn't replicated my post, so I
    couldn't inform everyone.

    Thanks anyway!

    Paul

    "Phillip Williams" <> wrote in message
    news:...
    > AutoGenerateColumns ="true" , e.g.
    >
    >
    > <asp:gridview ID="Gridview1" runat="server" DataSourceID="SqlDataSource1"
    > AutoGenerateColumns ="true" >
    > </asp:gridview>
    > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    > ConnectionString="<%$
    > ConnectionStrings:NorthwindConnectionString %>"
    > SelectCommand="SELECT [ProductName], [SupplierID], [CategoryID],
    > [UnitsInStock], [UnitPrice], [UnitsOnOrder] FROM [Alphabetical list of
    > products]">
    > </asp:SqlDataSource>
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "Paul Aspinall" wrote:
    >
    >> Hi
    >> I'm binding a DataSet, using the ObjectDataSource control, to a GridView
    >>
    >> I want the GridView to default to the columns returned in the DataSet,
    >> without having to specifically name them.
    >>
    >> How can I do this in code??
    >>
    >> Thanks
    >>
    >>
    >>
    Paul Aspinall, Nov 29, 2005
    #3
    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. Sergei Shelukhin
    Replies:
    1
    Views:
    556
    Mark Rae
    Nov 12, 2006
  2. Chris McGrath

    Displaying Fields in GridView

    Chris McGrath, May 24, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    341
    Alexey Smirnov
    May 24, 2007
  3. mharness
    Replies:
    2
    Views:
    451
  4. call_me_anything
    Replies:
    4
    Views:
    448
    Pete Becker
    Sep 30, 2007
  5. Cyril.Liu
    Replies:
    0
    Views:
    432
    Cyril.Liu
    Dec 2, 2008
Loading...

Share This Page