不知道哪里错...请帮个忙..在前台..数据库是accessDefault.aspx
<%@ Page Language="C#" Debug="true" MasterPageFile="~/show.master" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="_default" Title="文件展示" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<div style="width:285px;">
<div style="width:285px; background-image:url(images/sk2.jpg); height:27px; line-height:27px; font-size:13px; font-weight:bold; color:White;">
<div style="float:left">最新上传软件</div>
<div style="float:right"><a href=typeIndex.aspx?act=new style="color:">【更多更新】</a></div>
</div>
<div style="border:1px #feb301 solid; width:283px; margin-top:5px;">
<asp:DataList ID="new_soft" runat="server">
<ItemTemplate>  [<%# soft_type_name(DataBinder.Eval(Container.DataItem,"classid").ToString()) %>] 
<a href=downfile.aspx?downId=<%# DataBinder.Eval(Container.DataItem,"Id") %>>
<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName")).Length > 14 ? Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName")).Substring(0, 14)+".." : Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName"))%>
</a>
</ItemTemplate>
</asp:DataList>
<asp:Label ID="isgood_info" runat="server"></asp:Label>
</div>
</div>
<td>
<div style="width:285px; margin-left:5px;">
<div style="width:285px; background-image:url(images/sk2.jpg); height:27px; line-height:27px; font-size:13px; font-weight:bold; color:White;">
<div style="float:left">下载排行榜</div>
<div style="float:right"><a href=typeIndex.aspx?act=hot style="color:">【更多排行】</a></div>
</div>
<div style="border:1px #feb301 solid; width:283px; margin-top:5px;">
<div>
<asp:DataList ID="hits_soft" runat="server">
<ItemTemplate>  [<%# soft_type_name(DataBinder.Eval(Container.DataItem,"classid").ToString()) %>] 
<a href=downfile.aspx?downId=<%# DataBinder.Eval(Container.DataItem,"Id") %>>
<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName")).Length > 14 ? Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName")).Substring(0, 14)+".." : Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName"))%>
</a>
</ItemTemplate>
</asp:DataList>
<asp:Label ID="Label1" runat="server"></asp:Label></div>
</div>
</div></td>
<td></td>
</tr></table>
</asp:Content>Default.aspx.csusing System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.new_softList();//最新上传软件
this.hist_softList();//下载排行榜
} protected void new_softList()
{
DataView dv = dTable("select top 27 * from fileMain order by Id desc", "fileMain");
this.new_soft.DataSource = dv;
this.new_soft.DataBind();
}
protected void hist_softList()
{
DataView dv2 = dTable("select top 27 * from fileMain order by downHits desc", "fileMain");
this.hits_soft.DataSource = dv2;
this.hits_soft.DataBind();
}
private DataView dTable(string query, string table)
{
OleDbConnection conn = publicCS.ceconn();
OleDbDataAdapter sda = new OleDbDataAdapter(query, conn);
DataSet ds = new DataSet();
sda.Fill(ds, table);
return ds.Tables[table].DefaultView;
}
protected string soft_type_name(string classid)
{
DataView dv3 = dTable("select * from fileType where id=" + classid + "","fileType");
if (dv3.Table.Rows.Count != 0)
{
return dv3.Table.Rows[0]["tName"].ToString();
}
else
{
return "0";
}
}}有兴趣探讨的请加QQ..注明asp.net
<%@ Page Language="C#" Debug="true" MasterPageFile="~/show.master" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="_default" Title="文件展示" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<div style="width:285px;">
<div style="width:285px; background-image:url(images/sk2.jpg); height:27px; line-height:27px; font-size:13px; font-weight:bold; color:White;">
<div style="float:left">最新上传软件</div>
<div style="float:right"><a href=typeIndex.aspx?act=new style="color:">【更多更新】</a></div>
</div>
<div style="border:1px #feb301 solid; width:283px; margin-top:5px;">
<asp:DataList ID="new_soft" runat="server">
<ItemTemplate>  [<%# soft_type_name(DataBinder.Eval(Container.DataItem,"classid").ToString()) %>] 
<a href=downfile.aspx?downId=<%# DataBinder.Eval(Container.DataItem,"Id") %>>
<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName")).Length > 14 ? Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName")).Substring(0, 14)+".." : Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName"))%>
</a>
</ItemTemplate>
</asp:DataList>
<asp:Label ID="isgood_info" runat="server"></asp:Label>
</div>
</div>
<td>
<div style="width:285px; margin-left:5px;">
<div style="width:285px; background-image:url(images/sk2.jpg); height:27px; line-height:27px; font-size:13px; font-weight:bold; color:White;">
<div style="float:left">下载排行榜</div>
<div style="float:right"><a href=typeIndex.aspx?act=hot style="color:">【更多排行】</a></div>
</div>
<div style="border:1px #feb301 solid; width:283px; margin-top:5px;">
<div>
<asp:DataList ID="hits_soft" runat="server">
<ItemTemplate>  [<%# soft_type_name(DataBinder.Eval(Container.DataItem,"classid").ToString()) %>] 
<a href=downfile.aspx?downId=<%# DataBinder.Eval(Container.DataItem,"Id") %>>
<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName")).Length > 14 ? Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName")).Substring(0, 14)+".." : Convert.ToString(DataBinder.Eval(Container.DataItem, "fileName"))%>
</a>
</ItemTemplate>
</asp:DataList>
<asp:Label ID="Label1" runat="server"></asp:Label></div>
</div>
</div></td>
<td></td>
</tr></table>
</asp:Content>Default.aspx.csusing System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.new_softList();//最新上传软件
this.hist_softList();//下载排行榜
} protected void new_softList()
{
DataView dv = dTable("select top 27 * from fileMain order by Id desc", "fileMain");
this.new_soft.DataSource = dv;
this.new_soft.DataBind();
}
protected void hist_softList()
{
DataView dv2 = dTable("select top 27 * from fileMain order by downHits desc", "fileMain");
this.hits_soft.DataSource = dv2;
this.hits_soft.DataBind();
}
private DataView dTable(string query, string table)
{
OleDbConnection conn = publicCS.ceconn();
OleDbDataAdapter sda = new OleDbDataAdapter(query, conn);
DataSet ds = new DataSet();
sda.Fill(ds, table);
return ds.Tables[table].DefaultView;
}
protected string soft_type_name(string classid)
{
DataView dv3 = dTable("select * from fileType where id=" + classid + "","fileType");
if (dv3.Table.Rows.Count != 0)
{
return dv3.Table.Rows[0]["tName"].ToString();
}
else
{
return "0";
}
}}有兴趣探讨的请加QQ..注明asp.net
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货