先看下后台代码,数据库用的是access.
designers.aspx.cs:
using System.Collections;
using System.Text;
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;

public partial class Designers : System.Web.UI.Page
{
         protected void Page_Load( object sender, EventArgs e)
        {
                 string strConn = System.Web.Configuration.WebConfigurationManager.ConnectionStrings[ "connStr"].ConnectionString;
                OleDbConnection Conn = new OleDbConnection(strConn);
                 string StrComm = string.Empty;
                StrComm = "select    id,Dname,jieshao from [designers] ";
                OleDbDataAdapter Comm = new OleDbDataAdapter(StrComm, Conn);

                DataSet ds = new DataSet();                                                     //DataSet 初试化
                Comm.Fill(ds, "Book");
                designers.DataSource = ds.Tables[ "Book"].DefaultView;
                designers.DataBind();
                     }


         protected string CutLongString( string longString, int charNum)
        {
                 if (longString.Trim().Length > charNum)
                {
                         return longString.Substring(0, charNum);
                }
                 else return longString.Trim();
        }        


}
前台绑定:
"designers" runat= "server"    RepeatColumns= "2"    
                RepeatDirection= "Horizontal"    
             >
        
        

        
"designtable">
        
"fenleitiaomu">"designers/<%# Eval("id ")%>.jpg"    alt= "" /> "id")%> " target="_blank "><%# Eval("Dname")%>
        
        

         <%# CutLongString(DataBinder.Eval(Container.DataItem, "jieshao").ToString(),12)%>        
        
    
                

        


        

        
web.config

        "connStr" connectionString= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\data.mdb" providerName= "System.Data.OleDb"/>