|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Binding/paging issue gridviewI am trying to bind a custom datasource to a gridview whilst paging is enabled. What is missing in this code to make the paging + binding work? thanks M <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Public Class person Dim _name As String Public Property Name() Get Return _name End Get Set(ByVal value) _name = value End Set End Property End Class Public Class PersonCollection : Inherits CollectionBase Sub New() MyBase.New() End Sub Public Property item(ByVal i As Integer) Get Return Me.List(i) End Get Set(ByVal value) Me.List(i) = value End Set End Property Public Sub add(ByVal item As person) Me.List.Add(item) End Sub End Class Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then GridView2.DataSource = bron() GridView2.DataBind() End If End Sub Protected Function bron() As PersonCollection Dim objPersonCollection As New PersonCollection For a As Integer = 0 To 3 Dim objPerson As New person objPerson.Name = "Name" + a.ToString objPersonCollection.add(objPerson) Next Return objPersonCollection End Function Protected Sub GridView2_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView2.PageIndexChanging End Sub Protected Sub GridView2_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView2.PageIndexChanged End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView2" runat="server" AllowPaging="True" PageSize="2" AutoGenerateColumns="False"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:RadioButtonList ID="rblCategories" SelectedValue="<%#Bind('Name') %>" runat="server"><asp:ListItem Text="John" Value="Name0"></asp:ListItem> <asp:ListItem Text="Nick" Value="Name1"></asp:ListItem> <asp:ListItem Text="Bob" Value="Name2"></asp:ListItem> <asp:ListItem Text="Ed" Value="Name3"></asp:ListItem> </asp:RadioButtonList></ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> </form> </body> </html> |
|||||||||||||||||||||||