datagrid的问题
源码:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="test10.aspx.vb" Inherits="WebApplication1.test10"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>test10</title>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DG" OnEditCommand="DG_ItemCommand" AutoGenerateColumns=False CellPadding=4 runat="server"> <!--出错地方-->
<Columns>
<asp:BoundColumn HeaderText="Book Title" DataField="Title"></asp:BoundColumn>
<asp:ButtonColumn CommandName="select" Text="Select!"></asp:ButtonColumn>
<asp:ButtonColumn CommandName="unselect" Text="Unselect!"></asp:ButtonColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</HTML>
----------------------------------------
Imports System.Data.SqlClient
Public Class test10
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
Protected WithEvents DG As System.Web.UI.WebControls.DataGrid
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
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
If Not IsPostBack Then
Dim con As SqlConnection
Dim com As SqlCommand
con = New SqlConnection("server=samsung;user id=sa;password=;database=pubs;connection reset=false")
com = New SqlCommand("select * from Titles", con)
con.Open()
DG.DataSource = com.ExecuteReader()
DG.DataBind()
con.Close()
End If
End Sub
Private Sub DG_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG.ItemCommand
If e.CommandName = "select" Then
e.Item.BackColor = System.Drawing.Color.LightGreen
e.Item.Font.Bold = True
Else
e.Item.BackColor = System.Drawing.Color.White
e.Item.Font.Bold = False
End If
End Sub
End Class
--------------------------------------------------
出错原因:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'dg_edit' is not a member of 'ASP.test10_aspx'.
请问是什么原因?谢谢