Imports System.Data
Imports System.Data.SqlClient
Imports Ajax
Imports System
Imports System.Web
Imports System.Web.Caching
Partial Class UserControl_ProdIndex_Buyer
    Inherits System.Web.UI.UserControl
    Shared flag As Boolean
    Shared btn As LinkButton
    Shared chkflag As Boolean
    Shared dsj As New DataTable
    Shared pds As New DataSet
    Dim ds1 As New DataSet
    Dim dt1 As New DataTable

    Dim da As SqlDataAdapter
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Try

                If Request.QueryString("prodpage") = Nothing And Request.QueryString("sid") = Nothing Then

                    Session("prodpage") = 1
                    link_load("All")
                    ' loadProduct()

                ElseIf Request.QueryString("prodpage") = Nothing Then
                    Session("prodpage") = 1
                    getGridString(Request.QueryString("sid"))
                ElseIf Request.QueryString("sid") = Nothing Then
                    Session("prodpage") = Request.QueryString("prodpage")
                    'Session("ProdTable") = Nothing

                    loadProduct()
                Else
                    Session("prodpage") = Request.QueryString("prodpage")
                    'If IsNothing(Session("ProdTable")) Then
                    getGridString(Request.QueryString("sid"))
                    'End If

                    loadProduct()
                End If
                ' Panel1.Style.Add("visibility", "hidden")
            Catch ex As Exception
                Response.Write(ex.Message.ToString)
            End Try

        End If
    End Sub
    '<Ajax.AjaxMethod()> _
    'Public Function JProd(ByVal ProdName As String) As DataTable
    '    Try

    '        PBDT.DefaultView.RowFilter = "Product_Name ='" & ProdName & "'"
    '        PBDT.AcceptChanges()
    '        Dim dt As DataTable = PBDT.DefaultView.ToTable
    '        Return dt

    '    Catch ex As Exception
    '        Response.Write(ex.Message.ToString)
    '    End Try
    'End Function


    Private Sub loadProduct()
        Try
            If IsNothing(Session("ProdTable")) Then
                Dim dt As New DataTable
                Dim ds As New DataSet
                Dim con As New SqlConnection
                con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
                Dim Str As String
                
                Str = "SELECT * from ProductIndex order by Product_Name"
                ' Str = "select distinct lower(substring(LTrim(Product_Name),1,28)) as SProduct_Name,LTrim(Product_Name) as Product_Name from Product_Master where Product_Approved='Y' and Product_Isdeleted='0' order by product_name asc"
                If con.State = Data.ConnectionState.Open Then
                    con.Close()
                End If
                da = New SqlDataAdapter(Str, con)
                da.Fill(ds, "Product")
                dt = ds.Tables("Product")
                Session("ProdTable") = dt

            End If
            'End If

            Dim dt1 As DataTable

            dt1 = CType(Session("ProdTable"), DataTable).DefaultView.ToTable

            Dim dt2 As DataTable
            dt2 = CType(Session("ProdTable"), DataTable)

            If Request.QueryString("prodpage") = Nothing And Request.QueryString("sid") = Nothing Then
                dt1 = CType(Session("ProdTable"), DataTable)
            End If
            If Request.QueryString("sid") = Nothing Then
                dt1 = CType(Session("ProdTable"), DataTable)
            Else
                dt1 = CType(Session("ProdTable"), DataTable).DefaultView.ToTable
            End If

           

            If Request.QueryString("prodpage") <> Nothing Then


                Dim dtCat As New DataTable
                dtCat = dt1.Clone
                '''Dim start As Integer
                '''start = CType(dt.Rows(0).Item("Pindex").ToString(), Integer)
                Dim currentstart As Integer
                Dim currentend As Integer
                currentstart = ((CType(Request.QueryString("prodpage"), Integer) - 1) * 17)
                currentend = currentstart + 18

                While currentstart <> currentend
                    Try
                        dtCat.Rows.Add(dt1.Rows(currentstart).ItemArray)
                        currentstart = currentstart + 1
                    Catch ex As Exception
                        currentstart = currentend
                    End Try
                End While

                'gvprodsearch.Columns(1).Visible = True
                gvprodsearch.DataSource = dtCat.DefaultView.ToTable
                'ds.Tables("Product_Mast")
                gvprodsearch.DataBind()
                'gvprodsearch.Columns(1).Visible = False

                If gvprodsearch.Rows.Count < 17 Then
                    CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).Visible = False
                Else
                    CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).Visible = True
                End If

                If Session("prodpage") = "1" Then

                    CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).Visible = False
                    CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?prodpage=" & CType(Session("prodpage"), Integer) + 1)
                Else
                    Session("prodpage") = Request.QueryString("prodpage").ToString()
                    CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).Visible = True
                    CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?prodpage=" & CType(Session("prodpage"), Integer) - 1)
                    CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?prodpage=" & CType(Session("prodpage"), Integer) + 1)
                End If


                If Request.QueryString("sid") <> Nothing Then
                    CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?Sid=" & Request.QueryString("sid") & "&prodpage=" & CType(Session("prodpage"), Integer) - 1)
                    CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?Sid=" & Request.QueryString("sid") & "&prodpage=" & CType(Session("prodpage"), Integer) + 1)
                End If
                Exit Sub
            End If
            'End If

            gvprodsearch.DataSource = Nothing
            gvprodsearch.DataSource = dt1.DefaultView.ToTable

            gvprodsearch.DataBind()

            If gvprodsearch.Rows.Count < 17 Then
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).Visible = False
            Else
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).Visible = True
            End If

            If Session("prodpage") = "1" Then

                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).Visible = False
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?prodpage=" & CType(Session("prodpage"), Integer) + 1)
            Else
                Session("prodpage") = Request.QueryString("prodpage").ToString()
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).Visible = True
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?prodpage=" & CType(Session("prodpage"), Integer) - 1)
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?prodpage=" & CType(Session("prodpage"), Integer) + 1)
            End If


            If Request.QueryString("sid") <> Nothing Then
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?Sid=" & Request.QueryString("sid") & "&prodpage=" & CType(Session("prodpage"), Integer) - 1)
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?Sid=" & Request.QueryString("sid") & "&prodpage=" & CType(Session("prodpage"), Integer) + 1)
            End If

        Catch ex As Exception
            Response.Write(ex.Message.ToString)
        End Try
    End Sub

    Protected Sub gvprodsearch_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvprodsearch.PageIndexChanging
        If flag = True Then
            chkflag = True
            gvprodsearch.PageIndex = e.NewPageIndex
            Dim str As String = ""
            getGridString(Request.QueryString("sid"))
            'str = getGridString(Request.QueryString("sid"))
            'FillGrid(str)
        Else
            gvprodsearch.PageIndex = e.NewPageIndex
            loadProduct()
        End If

    End Sub

    Protected Sub getGridString(ByVal btn As String)
        Dim str As String = ""

        If IsNothing(Session("ProdTable")) Then
            Dim dt As New DataTable
            Dim ds As New DataSet
            Dim con As New SqlConnection
            con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
            Dim Str1 As String
            'Str = "SELECT DISTINCT LOWER(SUBSTRING(LTRIM(Product_Master.Product_Name), 1, 28)) AS SProduct_Name, Row_Number() over (order by RTrim(LTrim(Product_Name))) as PIndex, LOWER(REPLACE(LTRIM(RTRIM(Product_Master.Product_Name)), ' ', '-')) AS Product_Name, LOWER(REPLACE(REPLACE(REPLACE(Category_Master.Category_Name, ' ', '-'), ',', ''), '&-', '')) AS Category_name FROM Product_Master LEFT OUTER JOIN  Category_Master ON Product_Master.Product_CategoryId = Category_Master.Category_Kid WHERE (Product_Master.Product_Approved = 'Y') AND (Product_Master.Product_IsDeleted = '0') AND (Category_Master.Category_IsDeleted = '0') "
            'Str1 = "Select Product_Distinct.*, Row_Number() over (order by RTrim(LTrim(Product_Name))) as PIndex from Product_Distinct"
            Str1 = "SELECT * from ProductIndex order by Product_Name"
            ' Str = "select distinct lower(substring(LTrim(Product_Name),1,28)) as SProduct_Name,LTrim(Product_Name) as Product_Name from Product_Master where Product_Approved='Y' and Product_Isdeleted='0' order by product_name asc"
            If con.State = Data.ConnectionState.Open Then
                con.Close()
            End If
            da = New SqlDataAdapter(Str1, con)
            da.Fill(ds, "Product")
            dt = ds.Tables("Product")
            Session("ProdTable") = dt
        End If

        Select Case btn
            Case "All"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = ""
            Case "Abtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'A%' or Product_Name LIKE 'B%'or Product_Name LIKE 'C%' or Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"

                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'A%' or Product_Name LIKE 'B%'or Product_Name LIKE 'C%' or Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Bbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'B%'or Product_Name LIKE 'C%' or Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'B%'or Product_Name LIKE 'C%' or Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Cbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'C%' or Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'C%' or Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Dbtn"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
            Case "Ebtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Fbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' Product_Approved='Y' and Product_Isdeleted='0' and order by Product_Name asc "
            Case "Gbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Hbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Ibtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Jbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'order and Product_Approved='Y' and Product_Isdeleted='0' by Product_Name asc "
            Case "Kbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Lbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0'order by Product_Name asc "
            Case "Mbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Nbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Obtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Pbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Qbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Rbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Sbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Tbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Ubtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Vbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Wbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Xbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'order and Product_Approved='Y' and Product_Isdeleted='0' by Product_Name asc "
            Case "Ybtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
            Case "Zbtn"
                CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'Z%'"
                'str = "SELECT distinct Product_Name FROM Product_Master WHERE  Product_Name LIKE 'Z%' and Product_Approved='Y' and Product_Isdeleted='0' order by Product_Name asc "
        End Select
        'CType(Session("ProdTable"), DataTable).AcceptChanges()
        gvprodsearch.DataSource = CType(Session("ProdTable"), DataTable).DefaultView.ToTable
        gvprodsearch.DataBind()


        If CType(Session("ProdTable"), DataTable).DefaultView.ToTable.Rows.Count < 17 Then
            CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).Visible = False
        End If

        If Session("prodpage") = "1" Then

            CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).Visible = False
            CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?Sid=" & btn & "&prodpage=" & CType(Session("prodpage"), Integer) + 1)
        Else
            Session("prodpage") = Request.QueryString("prodpage").ToString()
            CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).Visible = True
            CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?Sid=" & btn & "&prodpage=" & CType(Session("prodpage"), Integer) - 1)
            CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?Sid=" & btn & "&prodpage=" & CType(Session("prodpage"), Integer) + 1)
        End If

    End Sub

   
    Private Sub link_load(ByVal btn As String)
        Try
            Dim str As String = ""
            If IsNothing(Session("ProdTable")) Then
                Dim dt As New DataTable
                Dim ds As New DataSet
                Dim con As New SqlConnection
                con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
                Dim Str1 As String
                Str1 = "SELECT * from ProductIndex order by Product_Name"
                If con.State = Data.ConnectionState.Open Then
                    con.Close()
                End If
                da = New SqlDataAdapter(Str1, con)
                da.Fill(ds, "Product")
                dt = ds.Tables("Product")
                Session("ProdTable") = dt
            End If

            Select Case btn
                Case "All"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = ""
                Case "A"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'A%' or Product_Name LIKE 'B%'or Product_Name LIKE 'C%' or Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "B"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'B%'or Product_Name LIKE 'C%' or Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "C"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'C%' or Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "D"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'D%' or Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "E"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'E%' or Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "F"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'F%' or Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "G"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'G%' or Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "H"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'H%' or Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "I"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'I%' or Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "J"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'J%' or Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "K"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'K%' or Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "L"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'L%' or Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "M"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'M%' or Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "N"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'N%' or Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "O"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'O%' or Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "P"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'P%' or Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "Q"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'Q%' or Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "R"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'R%' or Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "S"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'S%' or Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "T"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'T%' or Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "U"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'U%' or Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "V"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'V%' or Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "W"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'W%' or Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "X"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'X%' or Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "Y"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'Y%' or Product_Name LIKE 'Z%'"
                Case "Z"
                    CType(Session("ProdTable"), DataTable).DefaultView.RowFilter = "Product_Name LIKE 'Z%'"
            End Select
            gvprodsearch.DataSource = CType(Session("ProdTable"), DataTable).DefaultView.ToTable
            gvprodsearch.DataBind()


            If CType(Session("ProdTable"), DataTable).DefaultView.ToTable.Rows.Count < 17 Then
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).Visible = False
            End If

            If Session("prodpage") = "1" Then

                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).Visible = False
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?Sid=" & btn & "&prodpage=" & CType(Session("prodpage"), Integer) + 1)
            Else
                Session("prodpage") = Request.QueryString("prodpage").ToString()
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).Visible = True
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlBack"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?Sid=" & btn & "&prodpage=" & CType(Session("prodpage"), Integer) - 1)
                CType(gvprodsearch.FooterRow.Cells(0).FindControl("hrlNext"), HyperLink).NavigateUrl = ResolveUrl("~/buyer/newBuyerSearch.aspx?Sid=" & btn & "&prodpage=" & CType(Session("prodpage"), Integer) + 1)
            End If
        Catch ex As Exception
            ex.Message.ToString()
        End Try
    End Sub

    Protected Sub Abtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("A")
    End Sub

    Protected Sub Bbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("B")
    End Sub

    Protected Sub Cbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("C")
    End Sub

    Protected Sub Dbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("D")
    End Sub

    Protected Sub Ebtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("E")
    End Sub

    Protected Sub Fbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("F")
    End Sub

    Protected Sub Gbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("G")
    End Sub

    Protected Sub Hbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("H")
    End Sub

    Protected Sub Ibtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("I")
    End Sub

    Protected Sub Jbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("J")
    End Sub

    Protected Sub Kbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("K")
    End Sub

    Protected Sub Lbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("L")
    End Sub

    Protected Sub Mbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("M")
    End Sub

    Protected Sub Nbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("N")
    End Sub

    Protected Sub Obtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("O")
    End Sub

    Protected Sub Pbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("P")
    End Sub

    Protected Sub Qbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("Q")
    End Sub

    Protected Sub Rbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("R")
    End Sub

    Protected Sub Sbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("S")
    End Sub

    Protected Sub Tbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("T")
    End Sub

    Protected Sub Ubtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("U")
    End Sub

    Protected Sub Vbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("V")
    End Sub

    Protected Sub Wbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("W")
    End Sub

    Protected Sub Xbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("X")
    End Sub

    Protected Sub Ybtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("Y")
    End Sub

    Protected Sub Zbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        link_load("Z")
    End Sub
End Class
