Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 December 23rd, 2003, 05:30 PM
Registered User
 
Join Date: Dec 2003
Location: Bath, , United Kingdom.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default data grid in chapter 17, page 708

hi i can get the datagrid to display all the data and i can change the default property of what i want to sort by but when i acctually click the columns in the web page it does nothing!!

ive checked the code and the only thing i guess there could be a problem would be the datagrid itself, but all seems ok (it says the bit about javascript in the status etc!!)

HELP!

Grant

  #2 (permalink)  
Old January 16th, 2004, 01:48 AM
Registered User
 
Join Date: Jan 2004
Location: San Diego, CA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Grant,
I'm just a newbe but I mannaged to get this one to work.

I don't know what you did wrong but I have pasted my code below, being that their is no sample code for this one in the code download.
I sure hope this helps!
I am having trouble with the next exercise DataGrid Updates, check out my post.


Imports System.Data
Imports System.Data.SqlClient

Public Class WebForm1
    Inherits System.Web.UI.Page
    Protected WithEvents grdAuthors As System.Web.UI.WebControls.DataGrid

    ' Declare a connection object that is global in scope...
    Dim objConnection As SqlConnection

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

        ' Initialize the Connection object...
        objConnection = New SqlConnection("Server=New\NetSdk;database=pubs;Int egrated Security=sspi")

        ' Only bind the data the first time the page is built...
        ' Subsequent post backs will be to sort the data in the grid...
        If Not (IsPostBack) Then
            BindGrid("Last Name")

        End If

    End Sub

    Public Sub BindGrid(ByVal strSortField As String)
        ' Declare objects...
        Dim objDataSet As DataSet
        Dim objDataAdapter As SqlDataAdapter

        'Set the Sql String...
        objDataAdapter = New SqlDataAdapter( _
        "Select au_lname AS 'Last Name', au_fname AS 'First Name', " & _
        "Title AS 'Book Title', price AS 'Retail 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)

        ' Initialize the DataSet object and fill it...
        objDataSet = New DataSet()
        objDataAdapter.Fill(objDataSet, "Authors")

        ' Declare a DataView object, populate it,
        ' and sort the data in it...
        Dim objDataView As DataView = _
        objDataSet.Tables("Authors").DefaultView
        objDataView.Sort = strSortField

        ' Bind the DataView object to the DataGrid control...
        grdAuthors.DataSource = objDataView
        grdAuthors.DataBind()

        ' Clean up...
    End Sub

    Private Sub grdAuthors_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles grdAuthors.SortCommand
        ' Bind the DataGrid using the sort column requested
        BindGrid(e.SortExpression)
    End Sub

    Private Sub grdAuthors_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grdAuthors.SelectedIndexChanged

    End Sub
End Class
 


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
Chapter 17 - Report Data Source Granted BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 1 February 21st, 2006 10:53 AM
Data grid sorting on page 707 matejx BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 6 December 2nd, 2005 05:43 AM
problem in auto page navigation of data grid in AS kranthipriya ASP.NET 1.x and 2.0 Application Design 1 February 23rd, 2005 08:01 PM
DataGrid Updates BLANK PAGE (Chapter 17) happyhorseygal BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 April 8th, 2004 01:11 PM



All times are GMT -4. The time now is 05:19 AM.


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