Wrox Programmer Forums
|
BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6
This is the forum to discuss the Wrox book Beginning Visual Basic 2005 by Thearon Willis, Bryan Newsome; ISBN: 9780764574016
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 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 18th, 2009, 11:47 AM
Registered User
 
Join Date: Feb 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Gridview Chapter 17 error

Hi all,

Hopefully someone can help. Just started Visual Basic - using Visual Studio 2005 pro
and connecting to a sql database on a seperate server

Entered the code from the Try it Out on Page 575 with some amendments as follows to connect to the sql database.

<%@PageLanguage="VB"AutoEventWireup="false"CodeFile="Default.aspx.vb"Inherits="_Default" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
htmlxmlns="http://www.w3.org/1999/xhtml">
<
headrunat="server">
<title>Grid View</title>
</head>
<
body>
<formid="form1"runat="server">
<div>
<asp:sqlDataSourceID="tblAnimalTypes"runat="server"providername="System.Data.SqlClient"
connectionstring="Server=*********; User ID=AME;
password=********* ;database=AME;"
SelectCommand="SELECT txtAnimal, txtColour FROM tblAnimalTypes"
UpdateCommand="UPDATE tblAnimaltypes SET txtColour = @txtColour where txtAnimal = @original_txtAnimal">
<UpdateParameters>
<asp:ParameterType="String"Name="txtAnimal"/><asp:Parameter/>
<asp:ParameterType="String"Name="txtColour"/><asp:Parameter/>
</UpdateParameters>
</asp:sqlDataSource>
<asp:DataGridID="gdvAnimals"Runat="Server"DataSourceID="tblAnimalTypes"
allowpaging="true"AllowSorting="true"AutoGenerateColumns="true"DataKeyField="txtAnimal">
<PagerStyleBackColor="Gray"ForeColor="White"HorizontalAlign="Center"/>
<Headerstylebackcolor="black"ForeColor="white"/>
<AlternatingItemStyleBackColor="LightGray"/>
<Columns>
<
asp:CommandFieldbuttontype="Button"showeditbutton="true"/>
</Columns></asp:DataGrid></div>
</form>
</
body>
</
html>

Without the <asp:CommandField line the data grid is shown with data from the database but with any editing facilities

With the <asp:CommandField line the following error is given

Error 1 System.Web.UI.WebControls.DataGridColumnCollection must have items of type 'System.Web.UI.WebControls.DataGridColumn'. 'asp:CommandField' is of type 'System.Web.UI.WebControls.CommandField'. C:\WebSite\DataGridView\Default.aspx 31

The default.aspx.vb has the following

PartialClass _Default
Inherits System.Web.UI.Page
EndClass

Any help would be appreciated
 
Old February 19th, 2009, 11:49 AM
Registered User
 
Join Date: Feb 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Gridview Chapter 17 error

Found my problem

<asp:DataGrid should have read <asp:GridView





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error code: Chapter 17 Pag 576 luisxvarg BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 1 October 15th, 2007 08:06 PM
Chapter 17 First Try It Out paloyme BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 7 August 23rd, 2006 11:14 AM
Chapter 17 first Try It Out paloyme Visual Basic 2005 Basics 0 April 17th, 2006 04:34 AM
Chapter 17 Gaby BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 3 September 8th, 2005 11:50 AM





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