关于Repeater的数据问题  Category ,Products ,Brand ,name 的值我都传过来了 但是Repeater不显示数据。麻烦高手帮忙看下下面代码哪里出错了public void bind(int nPageIndex)
        {
            int Category = 0;   //大类ID
            int Products = 0;   //小类ID
            int Brand = 0;      //品牌ID
            int Province = 0;   //地区ID
            string Price = "";  //第1个价格
            string Price1 = "";   //第2个价格
            string name = "";
            if (Request.QueryString["Category"] != null)
            {
                if (Convert.ToInt32(Request.QueryString["Category"].ToString()) != 0)
                {
                    Category = Convert.ToInt32(Request.QueryString["Category"].ToString());
                }
            }
            if (Request.QueryString["Products"] != null)
            {
                if (Convert.ToInt32(Request.QueryString["Products"].ToString()) != 0)
                {
                    Products = Convert.ToInt32(Request.QueryString["Products"].ToString());
                }
            }
            if (Request.QueryString["Brand"] != null)
            {
                if (Convert.ToInt32(Request.QueryString["Brand"].ToString()) != 0)
                {
                    Brand = Convert.ToInt32(Request.QueryString["Brand"].ToString());
                }
            }
            if (Request.QueryString["Province"] != null)
            {
                if (Convert.ToInt32(Request.QueryString["Province"].ToString()) != 0)
                {
                    Province = Convert.ToInt32(Request.QueryString["Province"].ToString());
                }
            }
            if (Request.QueryString["Price"] != null)
            {
                Price = Request.QueryString["Price"].ToString();
            }
            if (Request.QueryString["Price1"] != null)
            {
                Price1 = Request.QueryString["Price1"].ToString();
            }
            if (Request.QueryString["SM_name"] != null)
            {
                name = Server.UrlDecode(Request.QueryString["SM_name"].ToString());
            }            int i, j;
            NetCMS.SuppliesBLL.Supplies_Middle b_sm = new NetCMS.SuppliesBLL.Supplies_Middle();            DataTable dt = b_sm.GetPage(Category, Products, Brand, Province, Price, Price1, name, nPageIndex, 9, out i, out j, null);
            if (dt.Rows.Count > 0)
            {                if (i > 9)
                {
                    this.PageNavigator1.PageCount = j;
                    this.PageNavigator1.PageIndex = nPageIndex;
                    this.PageNavigator1.RecordCount = i;
                    this.PageNavigator1.Visible = true;
                }
                else
                {
                    this.PageNavigator1.PageCount = j;
                    this.PageNavigator1.PageIndex = nPageIndex;
                    this.PageNavigator1.RecordCount = i;
                    this.PageNavigator1.Visible = false;
                }
                this.Repeater1.DataSource = dt;
                this.Repeater1.DataBind();
            }
            else
            {
                this.PageNavigator1.PageCount = j;
                this.PageNavigator1.PageIndex = nPageIndex;
                this.PageNavigator1.RecordCount = i;
                this.PageNavigator1.Visible = false;
            }
        }

解决方案 »

  1.   

    断点调试 看dt.Rows.Count的值 如果是有数据的却为0的话 就把b_sm.GetPage方法里面的查询语句直接在查询分析器里面查询 看是否能查出 
      

  2.   

    我一直用Repeater,把你前台页面代码帖出来,想检查一下你前台页面。
      

  3.   

    <asp:Repeater ID="Repeater1" runat="server">
                            <ItemTemplate>
                                <table width="530" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td width="24" rowspan="2" align="center" class="ypsj_xuxian">
                                            <span class="ypsj_jianju"></span>
                                        </td>
                                        <td width="134" rowspan="2" align="center" class="ypsj_xuxian">
                                            <a href="#">
                                                <img src="../yp_images/fyrw_qiche.jpg" /></a>
                                        </td>
                                        <td width="260" rowspan="2" align="left" valign="top" class="ypsj_xuxian">
                                            <p>&nbsp;
                                                </p>
                                            <a href='Supplies_Details.aspx?id=<%#Eval("SI_Id")%>&SM_Table=<%#Eval("SM_Table") %>'<!--WK 3.11号修改 &tablename改为&SM_Table -->
                                               <style="display: block; margin-top: 5px; margin-bottom: 5px; font-size: 14px;
                                                color: #0200CA">
                                                <%#Eval("SM_Name")%></a>
                                            <p>
                                                <%#Eval("SM_Introduce")%></p>
                                        </td>
                                        <td width="122" height="30">
                                            <p style="color: red; font-size: 14px; font-szie: 14px">&nbsp;
                                                </p>
                                            <p style="color: red; font-size: 14px; font-szie: 14px">
                                                ¥<%#Eval("SI_Price") %></p>
                                            <p style="color: #058100">
                                                <%#Eval("SM_AddTime")%></p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="122" height="90" align="left" class="ypsj_xuxian">&nbsp;
                                            
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:Repeater>
      

  4.   

    我只传值Province=12 为什么显示的数据不对呢
      

  5.   

    单步跟踪调试,只用一个字段
    字段是否一致,加try catch
      

  6.   

    你的数据层和逻辑层代码呢?
    Repeater的数据问题 Category ,Products ,Brand ,name 的值我
    ===
    没有转换成字符串类型啊