<!--源文件:template.aspx-->
<%@ Register TagPrefix="Acme" TagName="stuList" Src="template.ascx" %>
<html>
<body style="font: 10pt verdana">
<b><center><h3>模板示例</h3></center></b>
<form runat="server">
<Acme:stuList runat="server"/>
</form>
</body>
</html>
<!--源文件:template.ascx-->
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
If Not (Page.IsPostBack)
Dim DS As DataSet
Dim MyConnection As SQLConnection
Dim MyCommand As SQLDataSetCommand
MyConnection = New SQLConnection("server='iceberg';uid=sa;pwd=;database=info")
MyCommand = New SQLDataSetCommand("select * from infor where dept='" & Category.SelectedItem.Value & "'", MyConnection)
DS = New DataSet()
MyCommand.FillDataSet(DS, "infor")
MyDataList.DataSource = DS.Tables("infor").DefaultView
MyDataList.DataBind()
End If
End Sub
Sub Category_Select(Sender As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As SQLConnection
Dim MyCommand As SQLDataSetCommand
MyConnection = New SQLConnection("server='iceberg';uid=sa;pwd=;database=info")
MyCommand = New SQLDataSetCommand("select * from infor where dept='" & Category.SelectedItem.Value & "'", MyConnection)
DS = New DataSet()
MyCommand.FillDataSet(DS, "infor")
MyDataList.DataSource = DS.Tables("infor").DefaultView
MyDataList.DataBind()
End Sub
</script>
<table style="font: 10pt verdana">
<center>
<tr>
<center><td><b>请选择系名:</b></td></center>
<td style="padding-left:15">
<center>
<ASP:DropDownList AutoPostBack="true" id="Category" OnSelectedIndexChanged="Category_Select" runat="server">
<ASP:ListItem value="信息系">信息系</ASP:ListItem>
<ASP:ListItem value="工程系">工程系</ASP:ListItem>
<ASP:ListItem value="英语系">英语系</ASP:ListItem>
</ASP:DropDownList>
</center>
</td>
</tr>
</table>
<ASP:DataList id="MyDataList" BorderWidth="0" RepeatColumns="2" runat="server">
< itemtemplate>
<table cellpadding=10 style="font: 10pt verdana">
<tr>
<td valign="top">
<b>所在系: </b><%# DataBinder.Eval(Container.DataItem, "dept") %><br>
<b>姓名: </b><%# DataBinder.Eval(Container.DataItem, "name") %><br>
<b>性别: </b><%# DataBinder.Eval(Container.DataItem, "sex") %><br>
<b>年级: </b><%# DataBinder.Eval(Container.DataItem, "grade") %>
</td>
</tr>
</table>
</itemtemplate>
</ASP:DataList>
以上程序运行时提示如下错误:
分析器错误
说明: 在分析向此请求提供服务所需资源时出错。请检查下列特定分析错误详细信息并适当地修改源文件。
分析器错误信息: 类型“System.Web.UI.WebControls.DataList”不具有名为“template”的属性。
源错误:
源文件: D:\czyaspnet\webcontrol\template.ascx 行: 51
求求大家帮助我调试一下,这种错误我遇到了很多次,每次都无法解决,希望那位高手指导一下!谢谢谢谢!
行 49:
行 50: <ASP:DataList id="MyDataList" BorderWidth="0" RepeatColumns="2" runat="server">
行 51: <template name="itemtemplate">
行 52: <table cellpadding=10 style="font: 10pt verdana">
行 53: <tr>