Imports System
Imports System.Data
Imports System.Data.SqlClient
Partial Class category1_Metalworking_Welding_ShopSupplies
    Inherits System.Web.UI.Page
    Dim catid As String
    Dim con1 As New SqlConnection
    Dim DRow() As DataRow
    Dim dtCategoryDistinct As DataTable
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If IsNothing(CatDistinct) Then
                GetCatDistinct()
            End If
            'Session("CategoryDistinct") = ReturnDataTable("Select * from CategoryDistinct")
            dtCategoryDistinct = CatDistinct
            con1.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
            Dim Strr As String
            Dim lnk As New LinkButton
            Strr = "select Category_Kid from CategoryDistinct where Category_ParentId ='00000T1' order by category_name asc"
            If con1.State = Data.ConnectionState.Open Then
                con1.Close()
            End If
            Session("MainCat") = "00000T1"
            con1.Open()
            Dim da As New SqlDataAdapter(Strr, con1)
            Dim ds As New DataSet
            da.Fill(ds)
            Dim i As Integer = 1
            Dim j As Integer = 0
            For j = 0 To ds.Tables(0).Rows.Count - 1
                catid = ds.Tables(0).Rows(j).Item(0).ToString
                'Dim gv As New GridView

                'gv.ID = "gv" & i
                If j = 0 Then
                    bottomCategory(catid, gv1)
                End If
                If j = 1 Then
                    bottomCategory(catid, gv2)
                End If
                If j = 2 Then
                    bottomCategory(catid, gv3)
                End If
                If j = 3 Then
                    bottomCategory(catid, gv4)
                End If
                If j = 4 Then
                    bottomCategory(catid, gv5)
                End If

                If j = 5 Then
                    bottomCategory(catid, gv6)
                End If
                If j = 6 Then
                    bottomCategory(catid, gv7)
                End If
                If j = 7 Then
                    bottomCategory(catid, gv8)
                End If
                If j = 8 Then
                    bottomCategory(catid, gv9)
                End If
                If j = 9 Then
                    bottomCategory(catid, gv10)
                End If
                If j = 10 Then
                    bottomCategory(catid, gv11)
                End If
                'If j = 11 Then
                '    bottomCategory(catid, gv12)
                'End If
            Next

            con1.Close()

        End If
    End Sub
    
    Protected Sub gv1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim strCatID As String
            strCatID = e.Row.Cells(1).Text
            'Dim boolCat As String
            DRow = dtCategoryDistinct.Select("Category_ParentId='" & strCatID & "'")
            '            boolCat = ReturnValue("Select CategoryName from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
            If DRow.Length > 0 Then
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
            Else
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
            End If


        End If
    End Sub

    Protected Sub gv10_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv10.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim strCatID As String
            strCatID = e.Row.Cells(1).Text
            'Dim boolCat As String
            DRow = dtCategoryDistinct.Select("Category_ParentId='" & strCatID & "'")
            '            boolCat = ReturnValue("Select CategoryName from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
            If DRow.Length > 0 Then
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
            Else
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
            End If

        End If
    End Sub

    Protected Sub gv11_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv11.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim strCatID As String
            strCatID = e.Row.Cells(1).Text
            'Dim boolCat As String
            DRow = dtCategoryDistinct.Select("Category_ParentId='" & strCatID & "'")
            '            boolCat = ReturnValue("Select CategoryName from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
            If DRow.Length > 0 Then
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
            Else
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
            End If
        End If
    End Sub

    'Protected Sub gv12_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv12.RowDataBound
    '    If e.Row.RowType = DataControlRowType.DataRow Then
    '        Dim strCatID As String
    '        strCatID = e.Row.Cells(1).Text
    '        Dim boolCat As Boolean
    '        boolCat = IsAlreadyPresent("Select count(*) from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
    '        If boolCat Then
    '            CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
    '        Else
    '            CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
    '        End If


    '    End If
    'End Sub

    Protected Sub gv2_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv2.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim strCatID As String
            strCatID = e.Row.Cells(1).Text
            'Dim boolCat As String
            DRow = dtCategoryDistinct.Select("Category_ParentId='" & strCatID & "'")
            '            boolCat = ReturnValue("Select CategoryName from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
            If DRow.Length > 0 Then
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
            Else
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
            End If

        End If
    End Sub

    Protected Sub gv3_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv3.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim strCatID As String
            strCatID = e.Row.Cells(1).Text
            'Dim boolCat As String
            DRow = dtCategoryDistinct.Select("Category_ParentId='" & strCatID & "'")
            '            boolCat = ReturnValue("Select CategoryName from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
            If DRow.Length > 0 Then
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
            Else
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
            End If

        End If
    End Sub

    Protected Sub gv4_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv4.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim strCatID As String
            strCatID = e.Row.Cells(1).Text
            'Dim boolCat As String
            DRow = dtCategoryDistinct.Select("Category_ParentId='" & strCatID & "'")
            '            boolCat = ReturnValue("Select CategoryName from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
            If DRow.Length > 0 Then
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
            Else
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
            End If

        End If
    End Sub

    Protected Sub gv5_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv5.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim strCatID As String
            strCatID = e.Row.Cells(1).Text
            'Dim boolCat As String
            DRow = dtCategoryDistinct.Select("Category_ParentId='" & strCatID & "'")
            '            boolCat = ReturnValue("Select CategoryName from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
            If DRow.Length > 0 Then
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
            Else
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
            End If

        End If
    End Sub

    Protected Sub gv6_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv6.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim strCatID As String
            strCatID = e.Row.Cells(1).Text
            'Dim boolCat As String
            DRow = dtCategoryDistinct.Select("Category_ParentId='" & strCatID & "'")
            '            boolCat = ReturnValue("Select CategoryName from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
            If DRow.Length > 0 Then
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
            Else
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
            End If

        End If
    End Sub

    Protected Sub gv7_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv7.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim strCatID As String
            strCatID = e.Row.Cells(1).Text
            'Dim boolCat As String
            DRow = dtCategoryDistinct.Select("Category_ParentId='" & strCatID & "'")
            '            boolCat = ReturnValue("Select CategoryName from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
            If DRow.Length > 0 Then
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
            Else
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
            End If

        End If
    End Sub

    Protected Sub gv8_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv8.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim strCatID As String
            strCatID = e.Row.Cells(1).Text
            'Dim boolCat As String
            DRow = dtCategoryDistinct.Select("Category_ParentId='" & strCatID & "'")
            '            boolCat = ReturnValue("Select CategoryName from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
            If DRow.Length > 0 Then
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
            Else
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
            End If

        End If
    End Sub

    Protected Sub gv9_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv9.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim strCatID As String
            strCatID = e.Row.Cells(1).Text
            'Dim boolCat As String
            DRow = dtCategoryDistinct.Select("Category_ParentId='" & strCatID & "'")
            '            boolCat = ReturnValue("Select CategoryName from CategoryDistinct where Category_ParentId='" & RemoveLiterals(strCatID) & "'")
            If DRow.Length > 0 Then
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = Server.HtmlEncode(ResolveUrl("~/s3/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx"))
            Else
                CType(e.Row.Cells(0).FindControl("LinkButton1"), HyperLink).NavigateUrl = ResolveUrl("~/category/" & EncodeURL(RemoveLiterals(strCatID)) & "/" & e.Row.Cells(3).Text & "/" & e.Row.Cells(2).Text & ".aspx")
            End If

        End If
    End Sub
End Class
