ASP.NET 2.0 BasicsIf you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
let me explain you, I have three tables say table1,table 2, table3,
I want to display the column value id from table1, name from table 2 and company name from table3. Can I use single object data source to display them in grid view
<asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" AutoGenerateColumns="false" AllowPaging="true" GridLines="Both">
<asp:BoundField DataField="Company" HeaderText="Company" SortExpression="Company" />
<asp:BoundField DataField="# of Notes" HeaderText="# of Notes" SortExpression="# of Notes" />
<asp:BoundField DataField="# of Downloads" HeaderText="# of Downloads" SortExpression="# of Downloads" />
<asp:ObjectDataSource selectMethod="displayCust" ID="ObjectDataSource1" runat="server"></asp:ObjectDataSource> Can i user selectMethod="displayCust" for all three tables. If yes please explain, if not what is the option
In your code layer create a class that has the properties that you want to display. Then fire a SELECT statement against your database that gets the data from these three tables, possibly using a join.
In the object, copy the fields from the database (from a SqlDataReader for example) into your custom objects and return those objects to the ASPX page.
The GridView then displays the fields from the objects.