我有一个 GridView 如下:
<asp:GridView ID="gv" runat="server" SelectMethod="gv_GetData" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="true">
</asp:GridView>
我在 c# 中有以下有效的代码:
public IList<string> gv_GetData(int maximumRows, int startRowIndex, out int totalRowCount, string sortByExpression)
{
List<string> l = GetTestData();
totalRowCount = l.Count;
return l;
}
private List<string> GetTestData()
{
List<string> l = new List<string>();
l.Add("a");
l.Add("b");
l.Add("c");
return l;
}
现在,在 VB 中我有:
Public Function gv_GetData(maximumRows As Integer, startRowIndex As Integer, ByRef totalRowCount As Integer, sortByExpression As String) As IList(Of String)
Dim l As List(Of String) = GetTestData()
totalRowCount = l.Count
Return l
End Function
Private Function GetTestData() As List(Of String)
Dim l As New List(Of String)()
l.Add("a")
l.Add("b")
l.Add("c")
Return l
End Function
VB 版本总是产生以下错误:
When the DataBoundControl has paging enabled, either the SelectMethod should return an IQueryable or should have all these mandatory parameters : int startRowIndex, int maximumRows, out int totalRowCount
这可能是框架错误吗?还是我漏掉了一些过于明显的东西?
下面由 nemesv 回答。新方法是:
Public Function gv_GetData(maximumRows As Integer, startRowIndex As Integer, <System.Runtime.InteropServices.Out()> ByRef totalRowCount As Integer, sortByExpression As String) As IList(Of String)
Dim l As List(Of String) = GetTestData()
totalRowCount = l.Count
Return l
End Function
最佳答案
关于c# - 使用 vb 返回 IEnumerable 时,Asp.net 4.5 模型绑定(bind)中断?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12059456/