Displaying the default fields from a DataSet, to the GridView

P

Paul Aspinall

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
 
G

Guest

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>
 
P

Paul Aspinall

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 said:
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 said:
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
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top