我一直在尝试使用JQuery数据表使用列表视图而不是重复器以获取更多功能,但是我很难将其与数据库中的0值绑定
这是我的代码
<asp:ListView ID="lstArtigos" runat="server" GroupPlaceholderID="groupPlaceHolder1" ItemPlaceholderID="itemPlaceHolder1">
<LayoutTemplate>
<table id="tblArtigos" class="table table-bordered dataTable">
<thead class="thead-dark">
<tr>
<th style="width: 20px;">ID</th>
<th style="width: 120px">Ref. Cliente</th>
<th style="width: 100px">Ref. Interna</th>
<th style="width: 100px">Nome</th>
<th style="width: 100px">Estado</th>
<th style="width: 100px">Logística</th>
<th style="width: 100px">Info Logística</th>
<th style="width: 100px">Data Criação</th>
<th style="width: 10px;">Editar</th>
<th style="width: 10px;">Validar</th>
<th style="width: 10px;">Rejeitar</th>
</tr>
</thead>
<asp:PlaceHolder runat="server" ID="groupPlaceHolder1"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder1"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<td>
<asp:Label ID="lblIdArtigo" Text="<%# Eval("IdArtigo") %>"></asp:Label></td>
<td>
<asp:Label ID="lblRefCliente" Text="<%# Eval("ReferenciaCliente") %>"></asp:Label></td>
<td>
<asp:Label ID="lblRefInterna" Text="<%# Eval("ReferenciaInterna") %>"></asp:Label></td>
<td>
<asp:Label ID="lblNome" Text="<%# Eval("Nome") %>"></asp:Label></td>
<td>
<asp:Label ID="lblEstado" Text="<%# Eval("EstadoArtigo") %>"></asp:Label></td>
<td>
<asp:Label ID="lblAprovadoLogistica" Text="<%# Eval("AprovadoLogistica") %>"></asp:Label></td>
<td>
<asp:Label ID="lblInformacaoLogistica" Text="<%# Eval("InformacaoLogistica") %>"></asp:Label></td>
<td>
<asp:Label ID="lblDataCriacao" Text="<%# Eval("DataCriacao") %>"></asp:Label></td>
<td class="text-center">
<asp:ImageButton ImageUrl="/Images/Buttons/edit.png" CssClass="" Width="25" runat="server" />
</td>
<td class="text-center">
<asp:ImageButton ImageUrl="/Images/Buttons/success.png" CssClass="" Width="25" runat="server" />
</td>
<td class="text-center">
<asp:ImageButton ImageUrl="/Images/Buttons/x-button.png" CssClass="" Width="25" runat="server" />
</td>
</ItemTemplate>
</asp:ListView>
并且在代码背后,我将它与datatable绑定,即使它从数据库中为空,它也应该像在转发器上一样出现jquery消息
private void BindArtigos(int id)
{
lstArtigos.DataSource = Requisicao.GetAll(id);
lstArtigos.DataBind();
}
Jquery插件也没有问题,因为在编写列表视图之前我有一个中继器并且工作正常
编辑: 在表标题上添加了缺少的列,在控制台上仍然不显示任何内容,也没有错误
答案 0 :(得分:1)
问题在于,表主体中的单元格比thead
中的单元格更多。它们必须相同。
<thead class="thead-dark">
<tr>
<th style="width: 20px;">ID</th>
<th style="width: 120px">Ref. Cliente</th>
<th style="width: 100px">Ref. Interna</th>
<th style="width: 100px">Nome</th>
<th style="width: 100px">Logística</th>
<th style="width: 100px">Estado</th>
<th style="width: 10px;">Editar</th>
<th style="width: 10px;">Validar</th>
<th style="width: 10px;">Rejeitar</th>
//add these
<th># 1</th>
<th># 2</th>
</tr>
</thead>
答案 1 :(得分:0)
<td>
<asp:Label ID="lblIdArtigo" Text="<%# Eval("IdArtigo") %>"></asp:Label></td>
将此行替换为
<td>
<asp:Label ID="lblIdArtigo" Text='<%# Eval("IdArtigo") %>'></asp:Label></td>
并检查它是否显示数据
查看这篇文章
https://www.c-sharpcorner.com/UploadFile/9de7db/listview-control-in-Asp-Net/