注册 登录
编程论坛 ASP.NET技术论坛

Repeater不显示

swalia 发布于 2008-05-01 11:52, 1055 次点击
<asp:Repeater ID="Repeater1" runat="server">
                  <HeaderTemplate>
                  <table width="540" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="C96C82">
  <tr align="center" bgcolor="EED3D9">
    <td width="71" height="27"><font color="A90771"><b>乘机人</b></font></td>
    <td width="112" height="27"><font color="A90771"><b>订单号</b></font></td>
    <td width="85" height="27"><font color="A90771"><b>航程</b></font></td>
    <td width="49" height="27"><font color="A90771"><b>航班号</b></font></td>
    <td width="70" height="27"><font color="A90771"><b>起飞日期</b></font></td>
    <td width="70" height="27"><font color="A90771"><b>预订日期</b></font></td>
    <td width="61" height="27"><font color="A90771"><b>订单状态</b></font></td>
  </tr>
  </HeaderTemplate>
                <ItemTemplate>
  <tr align="center" bgcolor="EBF3FB">
    <td height="26"><asp:Repeater ID="childRepeater" runat="server" DataSource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("Userid") %>'>
    <ItemTemplate><%# DataBinder.Eval(Container.DataItem,"[\"Name\"]") %><br /></ItemTemplate></asp:Repeater></td>
    <td height="26"><a href="OrderModify.aspx?Orderid=<%#DataBinder.Eval(Container.DataItem,"OrderID")  %>"><Font color="blue"><%# DataBinder.Eval(Container.DataItem,"OrderID") %></Font></a></td>
    <td height="26"><%# DataBinder.Eval(Container.DataItem, "BeginCity")%> → <%#DataBinder.Eval(Container.DataItem, "EndCity")%></td>
    <td height="26"><%# DataBinder.Eval(Container.DataItem,"FlightNo") %></td>
    <td height="26"><%# DataBinder.Eval(Container.DataItem,"BeginDate","{0:d}")%></td>
    <td height="26"><%# DataBinder.Eval(Container.DataItem,"OrderTime","{0:MM-dd HH:mm}" )%></td>
    <td height="26"><img src='<%# DataBinder.Eval(Container.DataItem,"Status","IMGS/{0}.gif")%>' /></td>
  </tr>
  </ItemTemplate>
                <FooterTemplate>
</table>
</FooterTemplate>
                  </asp:Repeater>
CS代码
  strcon.Open();
         SqlDataAdapter da = new SqlDataAdapter("select* from FlightOrder where Userid='" + Session["Userid"].ToString() + "' and OrderTime> '" + DateTime.Today.AddDays(-14) + "'", strcon);
         da.Fill(ds1, "FlightOrder");
        
            SqlDataAdapter dat = new SqlDataAdapter("select* from FlightOrderDetail order by ID desc", strcon);
            dat.Fill(ds1, "FlightOrderDetail");
        
         try
         {  
            ds1.Relations.Add("Userid", ds1.Tables["FlightOrder"].Columns["OrderID"], ds1.Tables["FlightOrderDetail"].Columns["OrderID"]);
            this.Repeater1.DataSource = ds1;
            this.Repeater1.DataBind();
            if (this.Repeater1.Items.Count == 0)
            {
                this.Panel1.Visible = true;
                this.Panel2.Visible = false;
                this.Labmessage.Text = "您近两周内没有新订单,请您在订单查询中查找您的以前订单(本系统只保留60天订单)";
            }
            else
            {
                this.Panel1.Visible = false;
                this.Panel2.Visible = true;
            }
         }
         catch (Exception ex)
         {
            //throw ex;
         }
         finally
         {
为什么表里面的Userid两个数据不同时就不显示??
4 回复
#2
beniao2008-05-01 16:40
不能满足条件他当然是不会显示出数据的.
#3
swalia2008-05-01 16:46
那要怎么改?????
#4
beniao2008-05-01 17:05
回复 3# 的帖子
做程序前可以使用
GridView测试下是否查询到数据
#5
swalia2008-05-02 14:21
但是我用户名一样的就可显示啊???
1