我有一个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版本始终生成以下错误:
当DataBoundControl启用了分页时,要么是SelectMethod 应该返回IQueryable或者应该拥有所有这些 强制参数: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
答案 0 :(得分:8)