user control无法显示,求助!

maya_aliaswavefront maya_aliaswavefront 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
一个很简单的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
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
maya_aliaswavefront
.NET社区 62,272 成员 668,968 内容