DataTables警告:请求第0行的未知参数“0”

时间:2015-06-15 10:50:58

标签: jquery vb.net datatables

我使用的是vb.net。我使用动态数据表,可以搜索,列出,更新和删除数据。但我的数据表没有任何问题。但是只有一个问题。当使包含Datatables的页面刷新时,我得到一个像这样的弹出错误。

Error message popup here

<form  style =" margin-top : 220px;" id="form2" runat="server">
      <table  id="liste" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Sil</th>
                    <th>Düzenle</th>
                    <th>Proje Referans Numarası</th>
                    <th>Proje Adı</th>
                    <th>Proje Detay</th>
                    <th>Kullanacak Olan Departman</th>
                    <th>Başlangıç tarihi</th>
                    <th>Başlangıç Saati</th>
                    <th>Bitiş Tarihi</th>
                    <th>Bitiş Saati</th>
                </tr>
            </thead>

            <tfoot>
                <tr>
                    <th>Sil</th>
                    <th>Düzenle</th>
                    <th>Proje Referans Numarası</th>
                    <th>Proje Adı</th>
                    <th>Proje Detay</th>
                    <th>Kullanacak Olan Departman</th>
                    <th>Başlangıç tarihi</th>
                    <th>Başlangıç Saati</th>
                    <th>Bitiş Tarihi</th>
                    <th>Bitiş Saati</th>
                </tr>
            </tfoot>

            <tbody>
                <tr>
                    <%Dim strBaglanti As String = "Data Source=127.0.0.1;Initial Catalog=YOTK_TEST;Persist Security Info=True;User ID=username;Password=password"
                        Dim sayac = 0
                        Dim CN As New System.Data.SqlClient.SqlConnection(strBaglanti)
                        Dim strQ As String = "SELECT * FROM Proje"
                        Dim CMD As New System.Data.SqlClient.SqlCommand(strQ, CN)
                        CN.Open()
                        Dim Reader As System.Data.SqlClient.SqlDataReader = CMD.ExecuteReader()
                        Do While Reader.Read
                            Response.Write("<tr><td><center><a href='delete_project.aspx?id=" + Reader("ID").ToString() + "'><img width = '52px' height = '52px' src='css/images/delete.png'/></a></center></td><td><center><a href='edit_project.aspx?id=" + Reader("ID").ToString() + "'><img width = '52px' height = '52px' src='css/images/edit.png'/></a></center></td><td><center>" + Reader("ID").ToString + "</center></td><td><center>" + Reader("ProjeAdi").ToString + "</center></td><td><center><textarea style='width : 300px; height:100px;'>" + Reader("ProjeAciklama").ToString + "</textarea></center></td><td><center>" + Reader("Departman").ToString + "</center></td><td><center>" + Reader("BaslangicTarihi").ToString + "</center></td><td><center>" + Reader("BaslangicSaati").ToString + "</center></td><td><center>" + Reader("BitisTarihi").ToString + "</center></td><td><center>" + Reader("BitisSaati").ToString + "</center></td></tr>")
                        Loop
                        CN.Close()
                        %>
                </tr>
            </tbody>
    </table>
    </form>

这是我的表格代码

<script src="http://cdn.datatables.net/plug-ins/1.10.7/integration/jqueryui/dataTables.jqueryui.js"></script>
<script>
    $(document).ready(function() {
        $('#liste').dataTable();
    } );
</script>

这是我的JavaScript代码。有什么问题?

1 个答案:

答案 0 :(得分:1)

根据DataTables manual,其中一个原因可能是:

  • 表格中的单元格数量不满足等式#cells = #columns * #rows(即标题中定义的列数多于表格中的列数,反之亦然)。

您在VB代码之外定义了额外的<tr></tr>。下面是一个更正的代码,为简洁起见省略了其他部分。

            <tbody>
                    <%Dim strBaglanti As String = "Data Source=127.0.0.1;Initial Catalog=YOTK_TEST;Persist Security Info=True;User ID=username;Password=password"
                        Dim sayac = 0
                        Dim CN As New System.Data.SqlClient.SqlConnection(strBaglanti)
                        Dim strQ As String = "SELECT * FROM Proje"
                        Dim CMD As New System.Data.SqlClient.SqlCommand(strQ, CN)
                        CN.Open()
                        Dim Reader As System.Data.SqlClient.SqlDataReader = CMD.ExecuteReader()
                        Do While Reader.Read
                            Response.Write("<tr><td><center><a href='delete_project.aspx?id=" + Reader("ID").ToString() + "'><img width = '52px' height = '52px' src='css/images/delete.png'/></a></center></td><td><center><a href='edit_project.aspx?id=" + Reader("ID").ToString() + "'><img width = '52px' height = '52px' src='css/images/edit.png'/></a></center></td><td><center>" + Reader("ID").ToString + "</center></td><td><center>" + Reader("ProjeAdi").ToString + "</center></td><td><center><textarea style='width : 300px; height:100px;'>" + Reader("ProjeAciklama").ToString + "</textarea></center></td><td><center>" + Reader("Departman").ToString + "</center></td><td><center>" + Reader("BaslangicTarihi").ToString + "</center></td><td><center>" + Reader("BaslangicSaati").ToString + "</center></td><td><center>" + Reader("BitisTarihi").ToString + "</center></td><td><center>" + Reader("BitisSaati").ToString + "</center></td></tr>")
                        Loop
                        CN.Close()
                        %>
            </tbody>