控件绑定不显示数据,又不报错
数据库里面是有数据的
第一部分
<asp:Repeater ID= "Repeater1 " runat= "server ">
<ItemTemplate>
<table width= "99% " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td width= "10% "> <div align= "center "> <img src= "images/arrow-2.gif " width= "3 " height= "5 "> </div> </td>
<td> <%#DataBinder.Eval(Container.DataItem, "title ")%> </td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
第二部分
conndb dbcs = new conndb();
dbcs.connOpen();
string strsql;
strsql = "select Top 3 * from news where lanm= '企业新闻 ' ";
DataView dv = dbcs.connDv(strsql);
Repeater1.DataSource = dv;
Repeater1.DataBind();
第三部分
private OleDbConnection conn;
private OleDbCommand cmd;
public conndb() //在构造函数中创建连接
{
this.conn = new OleDbConnection(ConfigurationSettings.AppSettings[ "connstr "].ToString());
}
public DataView connDv(string strsql) //返回DataView对象
{
cmd = new OleDbCommand(strsql,conn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
return ds.Tables[0].D