repeater数据不显示,求大神们帮一下
Default.aspx.cs:
if (Session["yhm"] ==null)
{
Response.Redirect("login.aspx");
}
List<News> result = new List<News>();
Userbll ub = new Userbll();
result = ub.GetTop15();
if (result.Count > 0)
{
Repeater1.DataSource = result;
Repeater1.DataBind();
}
Default.aspx:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<ul>
<li><a href='<%#Eval("NEWSID","shownews.aspx?id={0}") %>'><%# Eval("NEWSTITLE")%></a></li>
</ul>
</ItemTemplate>
</asp:Repeater>
Userbll.cs:
public List<News> GetTop15()
{
List<News> result = new List<News>();
conn = new SqlConnection(DBhelp.StrConn);
try
{
conn.Open();
DBnews nd = new DBnews(conn, tran);
result = nd.SelectTop15();
conn.Close();
}
catch (Exception ex)
{
result = new List<News>();
}
finally
{
if (tran != null)
{
tran.Dispose();