|
|
 |
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

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
|
|
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
|

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
|
|
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 |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |