gpt4 book ai didi

asp.net - 分页 ListView 上的 MVC 项目

转载 作者:行者123 更新时间:2023-12-04 06:41:27 25 4
gpt4 key购买 nike

我正在使用 MVC 并将数据加载到 ListView 中。一切正常,这是 View :

<%  
Dim varDataSource As New iSAM.EntityiSAMRepository
ListViewDatos.DataSource = varDataSource.ListarCruceCertificadosPrecancelados
ListViewDatos.DataBind()
%>

<asp:ListView runat="server" ID="ListViewDatos">
<LayoutTemplate>
<table id="ListViewDatos" class="tablesorter" style="width:100%">
<thead>
<tr>
<th style="width:2%">
</th>
<th style="width:6%" align="left">
<a href="#" style="text-decoration:none"><font color="black">Póliza</font></a>
</th>
</tr>
</thead>

<tbody>
<tr id="itemPlaceholder" runat="server" />
</tbody>

<tfoot>
<tr id="pager" align="center">
<td colspan="7" style="border-right: solid 3px #7f7f7f;">
<asp:Image ID="Image1" ImageUrl="~/Images/first.png" CssClass="first" ToolTip="Inicio" runat="server" />
<asp:Image ID="Image2" ImageUrl="~/Images/prev.png" CssClass="prev" ToolTip="Anterior" runat="server" />
<input type="text" class="pagedisplay" readonly="readonly" style="width:100px; text-align:center" />
<asp:Image ID="Image3" ImageUrl="~/Images/next.png" CssClass="next" ToolTip="Siguiente" runat="server" />
<asp:Image ID="Image4" ImageUrl="~/Images/last.png" CssClass="last" ToolTip="Fin" runat="server" />
<select class="pagesize">
<option selected="selected" value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</td>
</tr>
</tfoot>
</table>
</LayoutTemplate>

<ItemTemplate>
<%
Static varCount As Long = 0
Dim varID1 As Long = Model(varCount).ID1
Dim varID2 As Long = Model(varCount).ID2
varCount = varCount + 1
%>

<tr>
<td style="border-width:medium">
<%=Html.CheckBox("chkCancel_" & Val(varID1) & "_" & Val(varID2), False, Nothing)%>
</td>
<td>
<%#Eval("WhatEver")%>
</td>
</tr>
</ItemTemplate>
</asp:ListView>

<p>
<input type="submit" value="Cancel" id="cmdCancel" onclick="if(!confirm('Are you sure?')) return false;" />
</p>

我的问题出在 Controller 上,因为我需要恢复加载到 ListView 中的所有复选框,但 Request.Form 仅返回根据分页显示的复选框,我的意思是,如果我使用 10 个项目的分页,那么 Request.Form 将获得 10复选框,正如我所说,我有 60 个复选框(例如),我需要使用 Request.Form 或其他东西(可能是一个技巧:))来获取 60 个复选框。
这是 Controller :
Function ListMyData(ByVal varErr As String) As ActionResult  
Dim arrIDs(,) As String = Nothing
Dim varcount As Long = 0

For Each varItem In Request.Form
If InStr(varItem.ToString, "chkCancel") > 0 Then
If Request.Form(varItem) = "true,false" Then
ReDim Preserve arrIDs(1, varCount)
Dim varCode As String = Mid(varItem, InStr(varItem, "_") + 1)
arrIDs(0, varCount) = Mid(varCode, 1, InStr(varCode, "_") - 1)
arrIDs(1, varCount) = Mid(varCode, InStr(varCode, "_") + 1)
varCount = varCount + 1
End If
End If
Next

Return View()
End Function

谢谢。

最佳答案

我不建议将 ASP.NET 控件与 MVC 混合使用。它们中的很多都需要在 MVC 中没有维护的状态。我在使用它们时总是遇到问题。

我建议您改用 MVCContrib 的网格或 jQuery 的网格。两者都很棒且易于使用。我倾向于使用 MCVContrib 的,因为我喜欢它的工作方式,而且我不需要花哨的客户端处理。

http://mvccontrib.codeplex.com/

关于asp.net - 分页 ListView 上的 MVC 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4188973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com