newbie to asp.net and problem with tutorial code

bcomtr

New Member
I've gone through the tutorial about paging records on the asp.net portion of this site. It displays records fine, but when I click on the next link, it gives me a javascript error saying "Object expected". Because I'm so new to .net, I don't know what to make of this. Does anyone see a problem with my code? I've copied most of it directly from the tutorial aside from my connection string and query. Thanks.<BR><BR><% @Import Namespace="System.Data"%><BR><% @Import Namespace="System.Data.SqlClient"%><BR><script language="vb" runat="server"><BR>sub page_load(sender as Object, e as EventArgs)<BR> if not Page.IsPostBack then<BR> BindData()<BR> end if<BR>end sub<BR><BR>sub BindData()<BR>'1. create a connection<BR>Dim myConnection as new SqlConnection(connStr)<BR>'2.Create command object, passing in sql string<BR>Const strSQL as String = "select carYear, Manufacturer, Model from Cars order by carYear"<BR><BR>dim myCommand as New SqlCommand(strSQL, myConnection)<BR><BR>'3. create the dataadapter<BR>Dim myDA as New SqlDataAdapter()<BR>myDA.SelectCommand = myCommand<BR><BR>'4. populate the dataset<BR>Dim myDS as new DataSet()<BR>myDA.Fill(myDS)<BR><BR>'5.set the datagrid's datasource to the dataset and databind<BR>dgPopularFAQs.DataSource = myDS<BR>dgPopularFAQs.DataBind()<BR>end sub<BR><BR>sub dgPopularFAQs_Paged(sender as Object, e as DataGridPageChangedEventArgs)<BR> dgPopularFAQs.CurrentPageIndex = e.NewPageIndex<BR> BindData()<BR>end sub<BR></script><BR><BR><BR><html><BR><body><BR><BR><BR><asp:datagrid id="dgPopularFAQs" runat="server" borderwidth="0"<BR> Cellpadding="2" width="100%"<BR> font-name="verdana"<BR> font-size="smaller"<BR><BR> headerStyle-HorizontalAlign="Center"<BR> headerStyle-Font-Bold="True"<BR> headerStyle-BackColor="Navy"<BR> headerStyle-ForeColor="White"<BR><BR> AlternatingItemStyle-BackColor="#dddddd"<BR> <BR> AllowPaging="True"<BR> PageSize="15"<BR> OnPageIndexChanged="dgPopularFAQs_Paged"><BR><PagerStyle Mode="NextPrev" NextPageText="<i>Next</i>" PrevPageText="<i>Previous</i>" Position="Bottom"><BR></PagerStyle><BR></asp:datagrid><BR><BR><BR></body><BR></html>Your datagrid needs to be in a server side form. <form runat="server"> </form>
 
Back
Top