Tengo un gridview de la siguiente manera:Asp.net 4.5 ¿El enlace del modelo se rompe al devolver IEnumerable usando vb?
<asp:GridView ID="gv" runat="server" SelectMethod="gv_GetData" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="true">
</asp:GridView>
tengo el siguiente código en C# que funciona:
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;
}
Ahora, en VB tengo:
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
La versión VB siempre genera el siguiente error:
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
¿Podría ser esto un error de framework? ¿O me estoy perdiendo algo demasiado obvio?
Respondido por nemesv a continuación. Nuevo método es:
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
Sí, lo has conseguido. Voy a publicar la corrección arriba. – John