Ich habe eine Gridview wie folgt:Asp.net 4.5 Modellbindung gebrochen, wenn IEnumerable mit VB zurückgegeben wird?
<asp:GridView ID="gv" runat="server" SelectMethod="gv_GetData" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="true">
</asp:GridView>
ich den folgenden Code in C#, das funktioniert: Jetzt
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;
}
, in VB ich habe:
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
Die VB-Version erzeugt immer den folgenden Fehler:
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
Könnte dies ein Framework-Fehler sein? Oder fehlt mir etwas zu offensichtlich?
Beantwortet von nemesv unten. Neue Methode ist:
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
Yup, Sie haben es genagelt. Ich werde die Korrektur oben veröffentlichen. – John