Error in converting app from 1.1 to framework 2.0

B

Blasting Cap

Juan:

That is correct - I am trying to convert a 1.1 app to 2.0, and seem to
have one page that continually fails.

The error messages I get are (all of this is in the ASPX I've posted
previously):

'Datagrid5_Sort' is not a member of 'ASP.sales_item_aspx'
'MyDatagrid_ItemDataBound' is not a member of 'ASP.sales_item_aspx'
'Datagrid5_select' is not a member of 'ASP.sales_item_aspx'.
'DGCustomer_sort' is not a member of 'ASP.sales_item_aspx'.

and so on.

I've created a new page (adding it to my sales folder in the
application), and pasted the stuff between the BODY tags on the Aspx
page in it, and pasted everything from the Page Load on from the aspx.vb
page into the new one & still get the errors.

Other pages that do sorts on the datagrid will build just fine.

In the ones causing the problem, the first line of the aspx page is:

<%@ Page Language="vb" AutoEventWireup="false" Inherits="test.Item"
enableViewState="True" CodeFile="Item.aspx.vb" %>

The aspx.vb/codefile has in it (this is everything above the Page Load
section):


Imports Microsoft.VisualBasic
Imports System.IO
Imports System.Data.SqlClient
Imports System
Imports System.Net
Imports System.Web
Imports System.Web.UI
Imports System.Data
Imports System.Text

'Partial Class Sales_Item
' Inherits System.Web.UI.Page

'End Class



Namespace test

Public Class Item
Inherits System.Web.UI.Page



#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


Dim strName As String
Dim nbrpos As Double
Dim orderqty As Double
Dim shipqty As Double
Dim sBol(5) As String
Dim sCarrier(5) As String
Dim orderval As Double
Dim shipval As Double
Dim sOrg As String = "0"
Dim sRegion As String = "0"
Dim sRep As String = "0"
'dim sDC as string = "0"
Dim sRestrict As String
Dim sAmmo As String
Dim sSold As String
Dim sShip As String
Dim sDCs As String


One of the other pages (with a sortable datagrid) that will build fine -
the first line of the aspx page has:

<%@ Page Language="VB" AutoEventWireup="false"
Inherits="test.ProgramSummary" enableViewState="True"
CodeFile="ProgramSummary.aspx.vb" %>

Everything above the Page Load in it is:

Imports System.Data.OleDb
Imports System.Data
Imports System.IO
Imports System.Data.SqlClient
Imports System
Imports System.Net
Imports System.Web
Imports System.Web.UI
'Imports System.Net.Mail
Imports System.Web.Mail
Imports System.Text


Namespace test


Partial Class ProgramSummary



Inherits System.Web.UI.Page




#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


I even thought the first statement on the datagrid might be a problem.
This one works:

<asp:datagrid id="Datagrid2" runat="server" ToolTip="Program Summary"
Width="100%" AllowSorting="True"
OnItemDataBound="mydatagrid_itemdatabound" ShowFooter="True"
AutoGenerateColumns="False" OnSortCommand="SortCommand_OnClick"
Font-Size="Small">

this one does not:

<asp:datagrid id="DataGrid5" runat="server" Font-Size="X-Small"
Width="800px" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None"
OnSelectedIndexChanged="DataGrid5_Select" DataKeyField="SKU"
AutoGenerateColumns="False" BorderWidth="1px" CellPadding="3"
ShowFooter="True" OnItemDataBound="MyDataGrid_ItemDataBound"
AllowSorting="True" OnSortCommand="DataGrid5_Sort">


BC
 
J

Juan T. Llibre

Try changing :

Namespace test
Public Class Item
Inherits System.Web.UI.Page

to :

Namespace test
Partial Class Item
Inherits System.Web.UI.Page
' rest of the code...
End Class ' this "End Class" is important, too!

The rest looks good to go.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
B

Blasting Cap

Juan:

I changed the page, and made your suggested changes. However, when I go
to build Page, it still returns those same 9 errors.


Error 1 'DataGrid5_Sort' is not a member of 'ASP.sales_aaa_aspx'.
C:\Inetpub\wwwroot\test\Sales\aaa.aspx 85
Error 2 'MyDataGrid_ItemDataBound' is not a member of
'ASP.sales_aaa_aspx'. C:\Inetpub\wwwroot\test\Sales\aaa.aspx 85
Error 3 'DataGrid5_Select' is not a member of 'ASP.sales_aaa_aspx'.
C:\Inetpub\wwwroot\test\Sales\aaa.aspx 85
Error 4 'DGCustomer_Sort' is not a member of 'ASP.sales_aaa_aspx'.
C:\Inetpub\wwwroot\test\Sales\aaa.aspx 136
Error 5 'DGCustomer_Select' is not a member of 'ASP.sales_aaa_aspx'.
C:\Inetpub\wwwroot\test\Sales\aaa.aspx 136
Error 6 'DGPOClass_Select' is not a member of 'ASP.sales_aaa_aspx'.
C:\Inetpub\wwwroot\test\Sales\aaa.aspx 161
Error 7 'DGPOList_Sort' is not a member of 'ASP.sales_aaa_aspx'.
C:\Inetpub\wwwroot\test\Sales\aaa.aspx 212
Error 8 'DGPOList_Select' is not a member of 'ASP.sales_aaa_aspx'.
C:\Inetpub\wwwroot\test\Sales\aaa.aspx 212
Error 9 'cmbPO_SelectedIndexChanged' is not a member of
'ASP.sales_aaa_aspx'. C:\Inetpub\wwwroot\test\Sales\aaa.aspx 292


(FYI - I have created a new page & pasted the Item code in this one and
am simply trying to build the page).

Line 85 above is:

<asp:datagrid id="DataGrid5" runat="server" Font-Size="X-Small"
Width="800px" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None"
OnSelectedIndexChanged="DataGrid5_Select" DataKeyField="SKU"
AutoGenerateColumns="False" BorderWidth="1px" CellPadding="3"
ShowFooter="True" OnItemDataBound="MyDataGrid_ItemDataBound"
AllowSorting="True" OnSortCommand="DataGrid5_Sort">


Any idea as to why this won't build?

BC
 
J

Juan T. Llibre

There is no real valid reason to use the DataGrid in ASP.NET 2.0.
You should use the GridView control instead.

Notice that in the ASP.NET 2.0 Data Controls tutorial, the DataGrid isn't even listed:
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/default.aspx

Read this MSDN article and learn to use the new ASP.NET 2.0 Gridview control :

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview(VS.80).aspx

The GridView control automates many tasks which had to be hand-coded in the DataGrid.

There's additional examples which show you how to use the GridView here :
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/gridview.aspx

Try it. You'll be glad you did.

Just create the GridView...and recycle your SQL statement, setting any other options you like/want.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
B

Blasting Cap

I'll take a look at the links.

However, why would 99 other datagrids convert into 2.0 just fine, and
the second one on this page won't do it?

BC
 
J

Juan T. Llibre

re:
!> I'll take a look at the links.

I'm sure you'll profit from them.

re:
!> However, why would 99 other datagrids convert into 2.0 just fine, and
!> the second one on this page won't do it?

No idea, but the Datagrid isn't the best data display/edit tool in ASP.NET 2.0.
It's the GridView. You should use the best tool for the best version.

You'll find it a lot easier to program the GridView, and it's more efficient, too.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top