Creating the Alphabetical List and Paging in GridView In ASP.NET

Custom Search

Step 1:

                   'gvList is GrirdView

Protected Sub gvList_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
    If e.Row.RowType = DataControlRowType.Footer Then
       
        Dim cell As TableCell = e.Row.Cells(0)
        cell.ColumnSpan = 2
       
        For i As Integer = 65 To (65 + 25)
            Dim lb As New LinkButton()
           
            lb.Text = [Char].ConvertFromUtf32(i) & " "
            lb.CommandArgument = [Char].ConvertFromUtf32(i)
            lb.CommandName = "AlphabeticalPaging"
           
            cell.Controls.Add(lb)
           
        Next
    End If
End Sub


Step 2:


Dim dt as New Datatable

Protected Sub gvCategories_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
    If e.CommandName.Equals("AlphabeticalPaging") Then
         dt = GetDataTable("SELECT ProductID, ProductName FROM Products WHERE ProductName LIKE '" & e.CommandArgument & "%'"       
      
        gvList.DataSource = dt
        gvList.DataBind()
    End If
End Sub
————————————————————————————————————————————————————————-

 del.icio.us  Stumbleupon  Technorati  Digg 

 

What did you think of this article?




Trackbacks
  • Trackbacks are closed for this entry.
Comments
Page: 1 of 1
Page: 1 of 1
Leave a comment

Submitted comments will be subject to moderation before being displayed.

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.