user control无法显示,求助!
一个很简单的user control,运行是无法显示,不知道是什么问题。麻烦请帮忙看一下~谢谢了!
DataList中添加了两个hyperlink
<asp:DataList id="list" runat="server" ForeColor="Black">
<SelectedItemTemplate>
<asp:HyperLink id="HyperLink2" runat="server" CssClass="CategorySelected"></asp:HyperLink>
</SelectedItemTemplate>
<ItemTemplate>
<asp:HyperLink id="HyperLink1" runat="server" CssClass="CategoryUnselected"></asp:HyperLink>
</ItemTemplate>
</asp:DataList>
相关的vb代码:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim listIndex As String = Request.Params("CategoryIndex")
If Not listIndex Is Nothing Then
list.SelectedIndex = CInt(listIndex)
End If
Dim catalog As New Catalog
list.DataSource = catalog.GetCategories()
list.DataBind()
End Sub
GetCategories()的代码:
Public Function GetCategories() As SqlDataReader
Dim connection As New SqlConnection(connectionString)
Dim command As New SqlCommand("GetCategories", connection)
command.CommandType = CommandType.StoredProcedure
connection.Open()
Return command.ExecuteReader(CommandBehavior.CloseConnection)
End Function
数据库的代码:
ALTER PROCEDURE GetCategories AS
SELECT CategoryID, CategoryName
FROM Categories
RETURN