请教:执行以下代码,为什么页面显示是空白的?
<%@ Import NameSpace="System.Data.SqlClient" %><%@ Import Namespace="System.Data" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication6.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<script language="VB" runat="server">
sub page_load(sender as Object,e as EventArgs)
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim ds as DataSet
myConnection = New SqlConnection( "server=192.168.0.103;database=Pubs;uid=sa;pwd=" )
myConnection.Open()
myCommand = New SqlCommand( "select * from [jobs]", myConnection )
MyDataGrid.DataSource=myCommand.ExecuteReader()
MyDataGrid.DataBind()
end sub
</script>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<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="MyDataGrid" runat="server" BorderColor="black" BorderWidth="1" GridLines="Both"
CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="10pt" HeaderStyle-BackColor="#aaaadd"
AlternatingItemStyle-BackColor="#eeeeee"></ASP:DataGrid>
</form>
</body>
</HTML>
--------------------编程问答-------------------- remove
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication6.WebForm1"%> --------------------编程问答-------------------- 请教下楼上,数据库有没有数据啊? --------------------编程问答-------------------- 呵呵,如果数据库表中没有数据,页面当然是空白,你可以在页面上随便拖个控件,写上一些初始化的值,看看是不是还是空白,如果不是,那就证明是数据绑定控件的问题了 --------------------编程问答-------------------- <script>标签换为 <% %> --------------------编程问答-------------------- 找到原因了,把AutoEventWireup更改为True就OK了
补充:.NET技术 , ASP.NET