Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 1st, 2008, 12:03 PM
Authorized User
Join Date: Sep 2007
Location: Rugeley, , United Kingdom.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB GridView & DetailsView

Yesterday I followed the book through Ch7 and managed to complete the exercises. Today I tried to apply some of what I thought I had learned to a web page for a Walking Group. I decided to create a page like the final Fixtures.aspx page, with a selectable GridView control listing walk activities and a DetailsView control to display information for the selected walk.
I prepared an Access database beforehand and added it into App_Data. I added the GridView and DetailsView controls to the page and linked them to the database, but I couldn't get it to work as I wanted. I could only get one record to display in the GridView.
After much fiddling, and re-reading the book, I decided to start from Fixtures.aspx and develop it how I wanted, which is to have 5 or 6 activities listed, with paging controls. But I can't get the GridView to behave, and I can't work out what it is that I've done to the working Fixtures.aspx page.

Here is my code:
<%@ Page Language="VB" MasterPageFile="~/site.master" AutoEventWireup="false" CodeFile="Fixtures.aspx.vb" Inherits="Fixtures" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:gridview ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="EventName,StartDate"
        DataSourceID="AccessDataSource1" EmptyDataText="There are no data records to display." AllowPaging="True">
            <asp:commandfield ShowSelectButton="True" />
            <asp:boundfield DataField="EventName" HeaderText="EventName" SortExpression="EventName" />
            <asp:boundfield DataField="StartDate" HeaderText="StartDate" SortExpression="StartDate" />
        <pagersettings FirstPageText="Oldest" LastPageText="Newest" Mode="NextPreviousFirstLast"
            Position="TopAndBottom" />
    <asp:accessdatasource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/EventManagement1.mdb"
        SelectCommand="SELECT [EventName], [StartDate], [EventID] FROM [Events] ORDER BY [StartDate]">
    <asp:detailsview ID="DetailsView1" runat="server" DataSourceID="AccessDataSource2" Height="50px"
        Width="340px" AutoGenerateRows="False" DataKeyNames="EventName,StartDate,EventDescription,StartTime,EmployeeID,Travel,WalkDistance,Location">
            <asp:boundfield DataField="EventName" HeaderText="EventName" SortExpression="EventName" />
            <asp:boundfield DataField="StartDate" HeaderText="StartDate" SortExpression="StartDate" />
            <asp:boundfield DataField="StartTime" HeaderText="StartTime" SortExpression="StartTime" />
            <asp:boundfield DataField="EventDescription" HeaderText="EventDescription" SortExpression="EventDescription" />
            <asp:boundfield DataField="WalkDistance" HeaderText="WalkDistance" SortExpression="WalkDistance" />
            <asp:boundfield DataField="Location" HeaderText="Location" SortExpression="Location" />
            <asp:boundfield DataField="Travel" HeaderText="Travel" SortExpression="Travel" />
            <asp:boundfield DataField="EmployeeID" HeaderText="EmployeeID" SortExpression="EmployeeID" />
    <asp:accessdatasource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/EventManagement1.mdb"
        SelectCommand="SELECT [EventID], [EventName], [Location], [StartDate], [StartTime], [EventDescription], [EmployeeID], [Travel], [WalkDistance] FROM [Events] WHERE ([EventID] = ?)">
            <asp:controlparameter ControlID="GridView1" DefaultValue="1" Name="EventID" PropertyName="SelectedValue"
                Type="Int32" />
Rugeley, UK
WinXP Pro SP2
VBW Express
Rugeley, UK
WinXP Pro SP2
VBW Express + SQL Server 2005 Express

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Gridview to Edit NOT DetailsView ? kalel_4444 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 December 4th, 2008 11:36 PM
VB: GridView & DetailsView in Master-Child Rich57 ASP.NET 2.0 Basics 1 May 29th, 2008 07:14 AM
Gridview & DetailsView Database Image Issue ayadrocks ASP.NET 2.0 Basics 1 December 27th, 2005 05:50 PM
Button on GridView that goes to DetailsView AndrewD ASP.NET 2.0 Basics 0 November 30th, 2005 11:09 AM
Can't get DetailsView to work with GridView oneworld95 ASP.NET 2.0 Basics 3 July 16th, 2005 07:19 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.