Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 分页列表视图上的MVC项目_Asp.net_Listview - Fatal编程技术网

Asp.net 分页列表视图上的MVC项目

Asp.net 分页列表视图上的MVC项目,asp.net,listview,Asp.net,Listview,我使用MVC,将数据加载到ListView中。一切正常,以下是视图: <% Dim varDataSource As New iSAM.EntityiSAMRepository ListViewDatos.DataSource = varDataSource.ListarCruceCertificadosPrecancelados ListViewDatos.DataBind() %> <asp:ListView runat="server" ID="Li

我使用MVC,将数据加载到ListView中。一切正常,以下是视图:

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

谢谢。

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

我建议您使用MVCContrib的网格或jQuery的网格。两者都很好用。我倾向于使用MCVContrib,因为我喜欢它的工作方式,不需要复杂的客户端处理


不要自欺欺人地认为自己在使用MVC。您使用的是经典的WebForms。与MVC无关。一旦您从视图中删除了所有包含
runat=“server”
的内容,您将更接近MVC。mvccontrib的网格非常棒,但要小心其中的一些其他代码-在我的项目中使用它时,我遇到了严重的性能问题。在做了一些分析之后,我把90%的CPU周期浪费在了一些写得很糟糕的MVCContrib代码上。问题中的bug已经修复,我没有任何其他问题,但这让我有点担心。在生产环境中依赖它之前,请确保您已经通过性能分析器运行了它。在提交时,我只能从实际页面捕捉复选框(结果是分页的)。正如我所说,我需要捕获所有标记为true的复选框。感谢您抽出时间来做一些谷歌研究。这个问题相当普遍,所以你应该能够找到一些东西。我也需要类似的功能。:)
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