后面代码:
  temp = "";
            if (temp == "")
            {
                  temp += " ANTE_PARTUM_EXAM.RESERVATION >= to_date('" + date_begin.Text + "','yyyy-mm-dd hh24:mi:ss') and ANTE_PARTUM_EXAM.RESERVATION < (to_date('" + date_end.Text + "','yyyy-mm-dd hh24:mi:ss')+1)";
            }
            else
            {
                 temp += " and ANTE_PARTUM_EXAM.RESERVATION >= to_date('" + date_begin.Text + "','yyyy-mm-dd hh24:mi:ss') and ANTE_PARTUM_EXAM.RESERVATION < (to_date('" + date_end.Text + "','yyyy-mm-dd hh24:mi:ss')+1)";
            }
           // }
            if (userRight == "2")
            {
                if (temp == "")
                    temp += " ANTE_PARTUM_EXAM.COMMUNITY_CODE = '" + communityCode + "' ";
                else
                    temp += " and ANTE_PARTUM_EXAM.COMMUNITY_CODE = '" + communityCode + "' ";
            }
            else if (userRight == "3")
            {
                if (temp == "")
                    temp += " ANTE_PARTUM_EXAM.EMP_NO = '" + empNo + "' and ANTE_PARTUM_EXAM.COMMUNITY_CODE = '" + communityCode + "'";
                else
                    temp += " and ANTE_PARTUM_EXAM.EMP_NO = '" + empNo + "' and ANTE_PARTUM_EXAM.COMMUNITY_CODE = '" + communityCode + "'";
            }
            //提取权限            ap_bll = new HISPlus.BLL.ANTE_PARTUM_EXAM();
            gridcount = ap_bll.GetList(temp).Tables[0].Rows.Count;
            if (gridcount > 0)
            {
                GridView1.DataSource = ap_bll.GetList(temp);
                GridView1.DataBind();
            }
            else
            {
                GridView1.DataBind();
            }前台gridview
<asp:LinkButton ID="lbtn_search" runat="server" OnClick="lbtn_search_Click"></asp:LinkButton>
                                        <asp:GridView ID="GridView1" runat="server" BorderWidth="0px" AllowSorting="True" 
                                            CellPadding="4" ForeColor="#333333" GridLines="None" DataKeyNames="RESERVATION,PATIENT_ID" 
                                            AutoGenerateColumns="False" AllowPaging="True" Width="100%"
                                            OnRowCreated="GridView1_RowCreated" 
                                            onpageindexchanging="GridView1_PageIndexChanging"  EmptyDataText="没有可显示的数据记录!"
                                            onrowdatabound="GridView1_RowDataBound" 
                                            ondatabound="GridView1_DataBound" 
                                            OnRowEditing="GridView1_RowEditing" onsorting="GridView1_Sorting">
                                            <%--以上是GridView的属性 --%>
                                            <PagerSettings Mode="NumericFirstLast" PageButtonCount="2" />
                                            <FooterStyle Font-Bold="True" ForeColor="#333333" />
                                            <RowStyle BackColor="#FFFFFF" HorizontalAlign="Center"/>
                                            <Columns>
                                                <asp:BoundField DataField="PATIENT_ID" HeaderText="居名姓名" ReadOnly="true" 
                                                    SortExpression="PATIENT_ID" />
                                                <asp:BoundField DataField="RESERVATION" HeaderText="随访日期" ReadOnly="true" SortExpression="RESERVATION" />
                                                <asp:BoundField HeaderText="距离天数"  />
                                                <asp:BoundField DataField="DOCTOR"  ReadOnly="true" SortExpression="DOCTOR" 
                                                    HeaderText="访视医生" />
                                                <%--查看按钮--%>
                                               
                                            </Columns>我设了断点调试,gridcount 是大于0的,为什么前台没有显示呢?

解决方案 »

  1.   

    GridView1.DataSource = ap_bll.GetList(temp).Table[0]保证你绑定的字段在数据源里存在
      

  2.   

    GridView1.DataSource = ap_bll.GetList(temp);
    改成GridView1.DataSource = ap_bll.GetList(temp).Table[0];试试gridview如果前台绑定了Sqldatasource,然后删除又重新进行后绑定,就会出现不显示数据的情况。一般可以删除该GridView,再重新拖一个。
      

  3.   

    如果count>0 看下绑定的字段对了吗 。