Skip to content

Instantly share code, notes, and snippets.

@JayDouglass
Created May 14, 2013 20:57
Show Gist options
  • Save JayDouglass/5579493 to your computer and use it in GitHub Desktop.
Save JayDouglass/5579493 to your computer and use it in GitHub Desktop.
Code behind for bootstrap GridView
Imports ChildNutrition.Web.Common.Validation
Imports ChildNutrition.Web.Common
Imports ChildNutrition.Web.Extensions
Imports ChildNutrition.Web.DataAccess
Namespace MonthlyClaims.Maintenance.SchoolDistrict
Public Class Search
Inherits BasePage
Dim schoolDistrictDataAccess As New SchoolDistrictDataAccess()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BindGrid(0)
End If
End Sub
Protected Sub btnSearch_Click(sender As Object, e As EventArgs)
BindGrid(0)
End Sub
Sub BindGrid(pageIndex As Integer)
gvSchoolDistricts.PageIndex = pageIndex
ValidateForm()
If FormState.IsValid Then
Dim pagedDataTable = schoolDistrictDataAccess.Query(pageIndex + 1, gvSchoolDistricts.PageSize, txtLEA.Text.NullIfEmpty(), txtFiscalYear.Text.Parse(Of Int16?), txtDistrictName.Text.NullIfEmpty())
gvSchoolDistricts.VirtualItemCount = CInt(pagedDataTable.TotalItems)
gvSchoolDistricts.DataSource = pagedDataTable.Table
gvSchoolDistricts.DataBind()
End If
End Sub
Sub ValidateForm()
txtLEA.StripNonAlphanumeric().Validate("LEA").IsLea()
txtFiscalYear.Validate("Fiscal Year").IsYear()
End Sub
Private Sub gvSchoolDistricts_PageIndexChanging(sender As Object, e As GridViewPageEventArgs) Handles gvSchoolDistricts.PageIndexChanging
BindGrid(e.NewPageIndex)
End Sub
End Class
End Namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment