2017-06-11 3 views
-1

Hier ist mein Code.Jquery Datentabelle in Listview funktioniert nicht

Der Ausgang ist "Keine Daten in der Tabelle verfügbar". Ich schätze es sehr und danke es im Voraus. Ich habe versucht, Datat-Code in Layout-Vorlage von Listview auch zu setzen.

<table id="example" class="display"> 
    <thead> 
     <tr> 
      all columns 
     </tr> 
    </thead> 
    <tfoot> 
     <tr> 
      all columns 
     </tr> 
    </tfoot> 
    <tbody> 

     <asp:ListView ID="lstfinance" runat="server"> 
      <LayoutTemplate> 
       <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder> 
      </LayoutTemplate> 
      <ItemTemplate> 
       <tr> 
        <td>Charde Marshall</td> 
        <td>Regional Director</td> 
        <td>San Francisco</td> 
        <td>36</td> 
        <td>2008/10/16</td> 
        <td>$470,600</td> 

       </tr> 
      </ItemTemplate> 
     </asp:ListView> 
    </tbody> 
</table> 
<script> 
    $(document).ready(function() { 
     $('#example').DataTable(); 
    }); 
</script> 
+0

Haben Sie an der rohen html der geladenen Seite sahen um zu sehen, ob es korrekt ist und die Daten tatsächlich auf die Seite geschoben wurden? – Bindrid

+0

Es wird alles geladen, mit Ausnahme der Daten, die sich innerhalb des -Tags befinden. –

Antwort

0

Ihr Code funktioniert nicht, da er nicht datengebunden ist, also leer ist. Hier ist eine Lösung, die Ihnen bis zu seiner Databound

so in Code hinter helfen:

protected void Page_Load(object sender, EventArgs e) 
    { 
     lstfinance.DataBind(); 
    } 

Und in der Content-Seite:

<table id="example" class="display"> 
    <thead> 
     <tr> 
      <th>Name</th> 
      <th>Position</th> 
      <th>City</th> 
      <th>Age</th> 
      <th>Start</th> 
      <th>Salary</th> 
     </tr> 
    </thead> 
    <tfoot> 
     <tr> 
      <th>Name</th> 
      <th>Position</th> 
      <th>City</th> 
      <th>Age</th> 
      <th>Start</th> 
      <th>Salary</th> 
     </tr> 
    </tfoot> 
    <tbody> 

     <asp:ListView ID="lstfinance" runat="server"> 
      <LayoutTemplate> 
       <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder> 
      </LayoutTemplate> 


      <EmptyDataTemplate> 
        <tr> 
        <td>Charde Marshall</td> 
        <td>Regional Director</td> 
        <td>San Francisco</td> 
        <td>36</td> 
        <td>2008/10/16</td> 
        <td>$470,600</td> 
       </tr> 
      </EmptyDataTemplate> 


      <ItemTemplate> 
        <tr> 
        <td>Charde Marshall</td> 
        <td>Regional Director</td> 
        <td>San Francisco</td> 
        <td>36</td> 
        <td>2008/10/16</td> 
        <td>$470,600</td> 
       </tr> 
      </ItemTemplate> 
     </asp:ListView> 
    </tbody> 
</table> 
+0

Vielen Dank. –

Verwandte Themen