Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003
This is the forum to discuss the Wrox book Professional VB.NET 2003 by Bill Evjen, Billy Hollis, Rockford Lhotka, Tim McCarthy, Jonathan Pinnock, Rama Ramachandran, Bill Sheldon; ISBN: 9780764559921
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 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 .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 14th, 2004, 03:04 AM
Registered User
Join Date: Jan 2004
Location: San Diego, CA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Rest of code for Chapter 17

The only code in the code download for chapter 17 is the Client-Server Processing project. I need the code for the DataGrid Updates project on page 711. Where can I get the code, As I am having allot of problems?

  #2 (permalink)  
Old March 6th, 2004, 05:32 PM
Authorized User
Join Date: Mar 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts

Im having the exact same problem!! :( I've written the the DataGrid Updates example out about 5 times from start to finish and keep getting a blank page when i load it. I have taken out the @page. If u do get it working can u post the code pls:D Cheers!!!!

  #3 (permalink)  
Old August 31st, 2004, 06:47 PM
Registered User
Join Date: Jul 2004
Location: duluth, mn, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

I noticed a lot of people have had lots of problems with chapter 17. Here is my code for the DataGrid Updates example. It is fully functionaly, after several hours of debugging typos :), so I hope it helps. Sorry about the formatting as it wraps around in some places as I just copy and pasted the code from the aspx document.


<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Import Namespace="System.Data"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
        <title>DataGrid Updates</title>
        <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
        <meta name="vs_defaultClientScript" content="VBScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <script runat=server language=vb>
    Dim objConnection as SqlConnection
    sub Page_Load(Sender as Object, E as EventArgs)
        objConnection=new SqlConnection("Server=(local);Initial Catalog=Pubs;User ID=sa;Password=pheonix;")
        If not (IsPostBack)
        End If
    End Sub
    Sub BindGrid()
        Dim objDataSet as DataSet
        dim objDataAdapter as SqlDataAdapter
        objDataAdapter = New SqlDataAdapter ( _
            "SELECT au_lname, au_fname, titles.title_id, title, price " & _
            "From authors " & _
            "Join titleauthor on authors.au_id=titleauthor.au_id " & _
            "Join titles on titleauthor.title_id = titles.title_id " & _
            "Order by au_lname, au_fname" , objConnection)
        objDataSet= new DataSet
        objDataAdapter.Fill(objDataSet, "authors")

    End Sub
    Sub EditGridData(Sender as Object, E as DataGridCommandEventArgs)
        grdAuthors.EditItemIndex = CInt(e.item.itemindex)
    End Sub
    Sub CancelGridData(Sender as Object, E as DataGridCommandEventArgs)
        grdAuthors.EditItemIndex = -1
    End Sub
    Sub UpdateGridData(Sender as Object, E as DataGridCommandEventArgs)
        Dim objCommand as SqlCommand
        dim objTextBox as TextBox
        Dim strSql as string= "Update titles Set title=@Title, price=@Price where title_id=@ID"

        objCommand=New SqlCommand(strSql, objConnection)
        objCommand.Parameters.Add(New SqlParameter("@ID", SqldbType.VarChar, 66))
        objCommand.Parameters.Add(New SqlParameter("@Title", SqldbType.VarChar, 80))
        objCommand.Parameters.Add(New SqlParameter("@Price", SqldbType.Money, 6))
        objCommand.Parameters("@ID").Value=grdAuthors.Data Keys(CInt(E.Item.ItemIndex))
        objCommand.Parameters("@Title").Value=objTextBox.T ext

        If Left(objTextBox.Text,1) = "$" Then
            objTextBox.Text= Right(objTextBox.Text, Len(objTextBox.Text)-1)
        End If
        objCommand.Parameters("@Price").Value=objTextBox.T ext
        grdAuthors.EditItemIndex = -1
    End Sub


    <body MS_POSITIONING="GridLayout">
        <form id="Form1" method="post" runat="server">
            <asp:DataGrid id="grdAuthors" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 40px"
                runat="server" Width="424px" Height="256px"
                <Columns >
                        EditText="Edit Row"
                        CancelText="Cancel Edit"
                        UPdateText="Update Row"
                    <asp:BoundColumn DataField="title_id" Visible=False />
                    <asp:BoundColumn DataField="au_lname" HeaderText="Last Name" ReadOnly=True ItemStyle-Wrap=False/>
                    <asp:BoundColumn DataField="au_fname" HeaderText ="First Name" ReadOnly=True ItemStyle-Wrap=False />
                    <asp:TemplateColumn HeaderText="title" ItemStyle-Wrap=False >
                        <ItemTemplate >
                            <asp:Label Runat=server Text='<%# DataBinder.Eval (Container.DataItem, "title") %>'/>
                            <asp:TextBox Runat=server ID="edit_title" Font-Name="Verdana" Font-size="8pt" Width="400" Text='<%# DataBinder.Eval (Container.DataItem, "title") %>'/>
                    <asp:TemplateColumn HeaderText="Price" HeaderStyle-Font-Bold=True ItemStyle-HorizontalAlign=Right>
                            <asp:Label Runat=server Text='<%# DataBinder.Eval (Container.DataItem, "price", "{0:C2}") %>'/>
                            <asp:TextBox Runat=server ID="edit_price" Font-Name="Verdana" Font-Size="8pt" Width="50" Text='<%# DataBinder.Eval (Container.DataItem, "price", "{0:C2}") %>'/>



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 06:56 AM.

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