mehfatitem
mehfatitem

Reputation: 147

DataTables warning: Requested unknown parameter `0` for row 0

I using vb.net. I use a dynamic datatable which can search, list, update and delete data. But my datatable works without any issue. But there is only one problem. When make the page which includes Datatables refresh, I get an popup error like this.

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>

This is my table code

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

This is my JavaScript code. What is the problem?

Upvotes: 2

Views: 2382

Answers (1)

Gyrocode.com
Gyrocode.com

Reputation: 58880

According to DataTables manual, one of the reasons it can occur is:

  • The number of cells in the table does not satisfy the equation #cells = #columns * #rows (i.e. there are more columns defined in the header than in the table body, or vice-versa).

You have extra <tr></tr> defined outside of your VB code. Below is a corrected code with other parts omitted for brevity.

            <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>

Upvotes: 1

Related Questions