标题:asp.net repeater老是无法显示数据, 怪!
只看楼主
guming
Rank: 4
等 级:业余侠客
威 望:5
帖 子:329
专家分:277
注 册:2006-11-9
结帖率:50%
已结贴  问题点数:10 回复次数:2 
asp.net repeater老是无法显示数据, 怪!
repeater老是无法显示数据, 怪!

cs/
<script runat="server">
private void Page_Load(object sender,System.EventArgs e)
{
querystr=Request.QueryString["searchn"].ToString();
proinfo_repter_bind();
}

void proinfo_repter_bind()
{
datacon();//链接数据库
string thestr="Select name from productiontb where name like'%"+querystr+"%'";
OleDbCommand theCOMD=accon.CreateCommand();

OleDbDataReader ckreader=theCOMD.ExecuteReader();
if(ckreader.Read())
{
thestr="Select name,imgurl,place,producetime,kucun,price,state from productiontb where name like'%"+querystr+"%'";
OleDbDataAdapter theADPT=new OleDbDataAdapter(thestr,accon);
DataSet thisDS=new DataSet();
theADPT.Fill(thisDS,"productiontb");
proinforpt.DataSource=thisDS.Tables["productiontb"].DefaultView;
proinforpt.DataBind();
accon.Close();
thisDS.Clear();
}
}
</script>


<html>
<form runat="server" method="post">
<asp:Repeater runat="server" ID="proinforpt">
 <headertemplate>
 <table width="100%" height="44" border="0" cellpadding="0" cellspacing="0">
 <asp:TemplateColumn>
  <tr align="center" valign="middle">
    <td>产品</td>
    <td>图片</td>
    <td>产地</td>
    <td>生产日期</td>
    <td>库存</td>
    <td>吨价</td>
    <td>简述</td>
  </tr>
  <tr align="center">
    <td><%# DataBinder.Eval(Container.DataItem,"name")%>cc</td>
    <td><%# DataBinder.Eval(Container.DataItem,"imgurl")%></td>
    <td><%# DataBinder.Eval(Container.DataItem,"place")%></td>
    <td><%# DataBinder.Eval(Container.DataItem,"producetime")%></td>
    <td><%# DataBinder.Eval(Container.DataItem,"kucun")%></td>
    <td><%# DataBinder.Eval(Container.DataItem,"price")%></td>
    <td><%# DataBinder.Eval(Container.DataItem,"state")%></td>
  </tr>
 </asp:TemplateColumn>
 </table>
 </headertemplate>
 </asp:Repeater>
</form>
</html>


[ 本帖最后由 guming 于 2009-11-25 16:14 编辑 ]
搜索更多相关主题的帖子: 数据 asp repeater 
2009-11-25 16:11
accpfriend
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:167
专家分:102
注 册:2006-12-31
得分:10 
<script runat="server">
private void Page_Load(object sender,System.EventArgs e)
{
querystr=Request.QueryString["searchn"].ToString();
proinfo_repter_bind();
}

void proinfo_repter_bind()
{
datacon();//链接数据库
string thestr="Select name from productiontb where name like'%"+querystr+"%'";
OleDbCommand theCOMD=accon.CreateCommand();

OleDbDataReader ckreader=theCOMD.ExecuteReader();
if(ckreader.Read())  //这里改成 when(chreader.read())
{
thestr="Select name,imgurl,place,producetime,kucun,price,state from productiontb where name like'%"+querystr+"%'";
OleDbDataAdapter theADPT=new OleDbDataAdapter(thestr,accon);
DataSet thisDS=new DataSet();
theADPT.Fill(thisDS,"productiontb");
proinforpt.DataSource=thisDS.Tables["productiontb"].DefaultView;
proinforpt.DataBind();
accon.Close();
thisDS.Clear();
}
}
</script>
2009-11-25 18:04
iamblizzardb
Rank: 1
等 级:新手上路
帖 子:4
专家分:1
注 册:2010-3-9
得分:0 
没有循环,哪能显示出来啊。
while(ckreader.Read())
{
thestr="Select name,imgurl,place,producetime,kucun,price,state from productiontb where name like'%"+querystr+"%'";
OleDbDataAdapter theADPT=new OleDbDataAdapter(thestr,accon);
DataSet thisDS=new DataSet();
theADPT.Fill(thisDS,"productiontb");
proinforpt.DataSource=thisDS.Tables["productiontb"].DefaultView;
proinforpt.DataBind();
accon.Close();
thisDS.Clear();
}
2010-03-09 19:52



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-293354-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.463669 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved