Jump to content

datagrid paging


Recommended Posts

Hi,By running this code

<%@ Import Namespace="System.Data" %><html><script language="VB" runat="server">	Dim startIndex As Integer	Function CreateDataSource() As ICollection		Dim dt As DataTable		Dim dr As DataRow		Dim i As Integer		'create a DataTable		dt = New DataTable		dt.Columns.Add(New DataColumn("IntegerValue", GetType(Integer)))		dt.Columns.Add(New DataColumn("StringValue", GetType(String)))		dt.Columns.Add(New DataColumn("DateTimeValue", GetType(String)))		dt.Columns.Add(New DataColumn("BoolValue", GetType(Boolean)))		' "query" should return one page of data, beginning at the start index		For i = startIndex to (startIndex + MyDataGrid.PageSize)			dr = dt.NewRow()			dr(0) = i			dr(1) = "Item " + i.ToString()			dr(2) = DateTime.Now.ToShortDateString			If (i Mod 2 <> 0) Then				dr(3) = True			Else				dr(3) = False			End If			dt.Rows.Add(dr)		Next		'return a DataView to the DataTable		CreateDataSource = New DataView(dt)	End Function	Sub Page_Load(sender As Object, e As EventArgs)		If Not IsPostBack Then			startIndex = 0			MyDataGrid.VirtualItemCount = 200		End If		BindGrid	End Sub	Sub MyDataGrid_Page(sender As Object, e As DataGridPageChangedEventArgs)		startIndex = e.NewPageIndex * MyDataGrid.PageSize		MyDataGrid.CurrentPageIndex = e.NewPageIndex		BindGrid	End Sub	Sub BindGrid()		MyDataGrid.DataSource = CreateDataSource()		MyDataGrid.DataBind	End Sub</script><body>	<h3><font face="Verdana">Custom Paging with DataGrid</font></h3>	<form runat=server>	  <ASP:DataGrid id="MyDataGrid" runat="server"		AllowPaging="True"		AllowCustomPaging="True"		PageSize="10"		PagerStyle-Mode="NumericPages"		PagerStyle-HorizontalAlign="Right"		OnPageIndexChanged="MyDataGrid_Page"		BorderColor="black"		BorderWidth="1"		GridLines="Both"		CellPadding="3"		CellSpacing="0"		Font-Name="Verdana"		Font-Size="8pt"		HeaderStyle-BackColor="#aaaadd"		AlternatingItemStyle-BackColor="#eeeeee"		/>  </form></body></html>

You will see the page number displays in the grid on the last row and first column. Is it possible on the last row to span all the column instead of having the 1st column only?Joe

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...