DA

我用SELECT  WHERE  语句选择表里的数据,然后再绑定到datalist的LABEL里<%#  DataBinder.Eval(Container.DataItem,  "question")  %>,怎么显示的数据少了一半?怎么解决?

解决方案 »

  1.   

    怎么显示的数据少了一半?datalist中是否做了设置
      

  2.   

    Dim conn As OleDbConnection
                Dim cmd, cm As OleDbDataAdapter
                conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("exam.mdb"))
                cmd = New OleDbDataAdapter("select  * from exam where type='panduan' ", conn)
                Dim ds As DataSet = New DataSet
                cmd.Fill(ds)
                DataList1.DataSource = ds
                DataList1.DataBind()
                conn.Close()
    是什么问题?
      

  3.   

    你是指question字段的数据不全,还是返回的记录数不全?
      

  4.   

    就是question还有些字段没有显示,条件type='panduan' 是满足的
      

  5.   

    先检查question字段类型,宽度;
    在sql里用select  * from exam where type='panduan'测试一下返回值
    看看是sql问题还是代码问题
      

  6.   

    另外,检查一下Label的css样式,看看是不是样式将溢出的字符截掉了
      

  7.   

    在数据库中测试select  * from exam where type='panduan'看返回的结果是怎么样的,
    还有在datalist中是不是使用了table固定了表格的话有时候会遮住一些字符。
      

  8.   

    我用datagrid来显示记录是可以的,然后用datalist的话,就少了一半记录,我也没改变datalist的设置。请问怎么办?
    前台代码
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="exam.aspx.vb" Inherits="examnationonline.exam"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>exam</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <table height="76" cellSpacing="1" cellPadding="0" width="760" align="center" border="0">
    <tr>
    <td class="style8" borderColor="#000000" align="center" bgColor="#e2f2ff" height="74"><img height="74" src="file:///G|/EXAM/kaoshi2/images/TOP.jpg" width="753">
    </td>
    </tr>
    </table>
    <table height="29" width="760" align="center" bgColor="#ffffff" border="0">
    <tr>
    <td width="126" bgColor="#afdbff">
    <fieldset>
    <div align="center"><IMG height="14" src="images/more01.gif" width="15">首页</div>
    </fieldset>
    </td>
    <td width="126" bgColor="#afdbff">
    <fieldset>
    <div align="center"><IMG height="14" src="images/more01.gif" width="15">练习</div>
    </fieldset>
    </td>
    <td width="126" bgColor="#afdbff">
    <fieldset>
    <div align="center"><IMG height="14" src="images/more01.gif" width="15">考试</div>
    </fieldset>
    </td>
    <td width="126" bgColor="#afdbff">
    <fieldset>
    <div align="center"><IMG height="14" src="images/more01.gif" width="15">成绩查询</div>
    </fieldset>
    </td>
    <td width="126" bgColor="#afdbff">
    <fieldset>
    <div align="center"><IMG height="14" src="images/more01.gif" width="15">用户管理</div>
    </fieldset>
    </td>
    <td width="126" bgColor="#afdbff">
    <fieldset>
    <div align="center"><IMG height="14" src="images/more01.gif" width="15">题库管理</div>
    </fieldset>
    </td>
    </tr>
    </table>
    <asp:datalist id="DataList1" runat="server">
    <SelectedItemTemplate>
    <FONT face="宋体"></FONT>
    </SelectedItemTemplate>
    <ItemTemplate>
    <asp:Label id="Label1" runat="server" Width="37px" Height="15px">
    <%# DataBinder.Eval(Container.DataItem, "id") %>
    </asp:Label><FONT face="宋体">、
    <asp:Label id="Label3" runat="server" Width="469px">
    <%# DataBinder.Eval(Container.DataItem, "question") %>
    </asp:Label></FONT>
    </ItemTemplate>
    <AlternatingItemTemplate>
    <FONT face="宋体"></FONT>
    </AlternatingItemTemplate>
    </asp:datalist>
    </form>
    </body>
    </HTML>
    后台代码
    Imports System.Data.OleDb
    Public Class exam
        Inherits System.Web.UI.Page#Region " Web 窗体设计器生成的代码 "    '该调用是 Web 窗体设计器所必需的。
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()    End Sub
        Protected WithEvents DataList1 As System.Web.UI.WebControls.DataList    '注意: 以下占位符声明是 Web 窗体设计器所必需的。
        '不要删除或移动它。
        Private designerPlaceholderDeclaration As System.Object    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
            '不要使用代码编辑器修改它。
            InitializeComponent()
        End Sub#End Region    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            '在此处放置初始化页的用户代码
            If Not IsPostBack Then
                Dim conn As OleDbConnection
                Dim cmd, cm As OleDbDataAdapter
                conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("exam.mdb"))
                cmd = New OleDbDataAdapter("select  * from exam where type='panduan' ", conn)
                Dim ds As DataSet = New DataSet
                cmd.Fill(ds)
                DataList1.DataSource = ds
                DataList1.DataBind()
                
                conn.Close()
               
            End If
        End SubEnd Class
      

  9.   

    将 DataList 控件的 RepeatColumns 属性设置为所需的列数
      

  10.   

    RepeatColumns改了也没用的,哪位高手知道到底怎么解决啊?为什么DATAGRID可以读出全部10记录,而DATALIST却只有1、3、5、7、9五条?
      

  11.   

    <AlternatingItemTemplate>
    <FONT face="宋体"></FONT>
    </AlternatingItemTemplate>
    ===
    问题在这里,你设定了交替项,去掉或改成
    <AlternatingItemTemplate>
    <asp:Label id="Label5" runat="server" Width="37px" Height="15px">
    <%# DataBinder.Eval(Container.DataItem, "id") %></asp:Label>
    <asp:Label id="Label6" runat="server" Width="469px"><%# DataBinder.Eval(Container.DataItem, "question") %></asp:Label>
    </AlternatingItemTemplate>