Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 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 June 29th, 2003, 01:04 PM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Why asm I getting the error below?

"AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid with ID DataGrid1 when AllowPaging is set to true and the selected datasource does not implement ICollection."

I keep reading how the property builder lets you create simple paging, but I keep getting the above error when I go into property builder and Select Paging, I put a check box in Allow Paging, I set Page Size to 5. Position defaults to Bottom, Mode defaults to NEXT, Previous buttons and Next Page Button Text defaults to > and Previous page button text defaults to < .

If I change any of the values, I still get the error. Here is my code:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="newdatagrid.WebForm1" Debug="False"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <title>WebForm1</title>
        <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
        <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
        <form id="Form1" method="post" runat="server">
            <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 214px; POSITION: absolute; TOP: 67px" autogeneratecolumns="False" runat="server" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" BackColor="White" CellPadding="3" GridLines="None" CellSpacing="1" AllowPaging="True" PageSize="5">
                <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#9471DE"></SelectedItemStyle>
                <ItemStyle ForeColor="Black" BackColor="#DEDFDE"></ItemStyle>
                <HeaderStyle Font-Bold="True" ForeColor="#E7E7FF" BackColor="#4A3C8C"></HeaderStyle>
                <FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>
                <PagerStyle HorizontalAlign="Right" ForeColor="Black" BackColor="#C6C3C6"></PagerStyle>
            </asp:DataGrid>
        </form>
    </body>
</HTML>
__________________________________________________ __________
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
        If Not IsPostBack Then
            OleDbConnection1.Open()
            Dim reader As System.Data.OleDb.OleDbDataReader
            reader = OleDbCommand1.ExecuteReader
            DataGrid1.DataSource = reader
            DataGrid1.DataBind()
            reader.Close()
            OleDbConnection1.Close()
        End If
End Sub
 
Old May 1st, 2004, 02:09 AM
Registered User
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi try the following code which uses the event handler

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        DatabindToGrid()
   End Sub

    Sub myDataGrid_PageChanger(ByVal Source As Object, _
    ByVal E As DataGridPageChangedEventArgs)
        ' Set the CurrentPageIndex before binding the grid
        DataGrid1.CurrentPageIndex = E.NewPageIndex
        DatabindToGrid()
    End Sub

    Sub DatabindToGrid()
        Dim ds As New DataSet
        Dim sda As SqlDataAdapter
        Dim strSQL As String
        Dim strCon As SqlConnection

        strSQL = "Select Schedule_id,user_id,date,descr from schedule"
        strCon = New SqlConnection("Data Source=ursource;database=urdb;UID=ur;Connection Lifetime = 180")
        strCon.Open()


        sda = New SqlDataAdapter(strSQL, strCon)
        sda.Fill(ds, "schedule")

        DataGrid1.DataSource = ds.Tables("schedule")
        DataGrid1.DataBind()
        strCon.Close()
    End Sub

in the html file of ur .aspx file

use this replacing your datagrid definition

<asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 48px" runat="server"
                Width="32px" Height="88px" BorderColor="Tan" BorderWidth="1px" BackColor="LightGoldenrodYellow"
                CellPadding="2" GridLines="None" ForeColor="Black" AllowPaging="True" PageSize="5" PagerStyle-Mode="NumericPages" OnPageIndexChanged="myDataGrid_PageChanger">

hope this will help you

Thomas


If u can u can if u can't then u r right
 
Old May 18th, 2004, 11:19 PM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to tianlang
Default

HI U try below
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
        If Not IsPostBack Then
            OleDbConnection1.Open()
            dim sda = New SqlDataAdapter(strSQL, strCon)// strSQL strCon is variable
        sda.Fill(ds, "schedule")

        DataGrid1.DataSource = ds.Tables("schedule")
        DataGrid1.DataBind()


         OleDbConnection1.Close()
        End If
End Sub
if u can't u try else





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
hi i got runtime error 13 Type Mismatch error sriharsha345 Access VBA 2 February 21st, 2008 09:30 AM
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 02:51 AM
VB Error: Syntax Error or Access Violation codehappy VB How-To 7 October 3rd, 2007 05:41 PM





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