Private Property DataTable() As DataTable Get Return DirectCast(Session("DataTable"), DataTable) End Get Set(ByVal value As DataTable) Session("DataTable") = value End Set End Property Protected Overrides Sub OnLoad(ByVal e As EventArgs) MyBase.OnLoad(e) If Not Me.IsPostBack Then Dim dt As DataTable If Me.DataTable Is Nothing Then dt = InlineAssignHelper(Me.DataTable, Me.LoadData()) Else dt = Me.DataTable End If Me.GridView3.DataSource = dt Me.GridView3.DataBind() Me.txtSearch.Attributes.Add("onkeyup", String.Format("javascript:__doPostBack('{0}','')", Me.upnlGridView.ClientID)) Else Dim target As String = Me.Request.Form("__EVENTTARGET") If Not String.IsNullOrEmpty(target) AndAlso target.Equals(Me.upnlGridView.ClientID) Then If Not String.IsNullOrEmpty(Me.txtSearch.Text) Then Dim dt As DataTable = Me.GetTable() For i As Integer = 0 To dt.Rows.Count - 1 dt = DirectCast(Session("DataTable"), DataTable) Dim dr As DataRow = dt.Rows(i) dt.Rows.Remove(dr) Next GridView3.DataBind() Dim rows As DataRow() = Me.DataTable.[Select](String.Format("Emp_Number LIKE '%{0}%'", Me.txtSearch.Text)) Me.GridView3.DataSource = Me.LoadData(rows) Me.GridView3.DataBind() Else Me.GridView3.DataSource = Me.DataTable Me.GridView3.DataBind() End If End If End If End Sub Public Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T target = value Return value End Function Protected Sub PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs) End Sub Protected Sub Sorting(ByVal sender As Object, ByVal e As GridViewSortEventArgs) End Sub Private Function LoadData() As DataTable Return Me.LoadData(Nothing) End Function
Session.Clear()
Session.Add("Mykeyname","")
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)