Imports System
Imports System.Data
Imports System.Data.SqlClient
Partial Class Catgory1_HVAC
    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
            'Dim dt As DataTable
            'dt = ReturnDataTable("Select Top(1) from CategoryDistinct")

            'Dim dr As DataRow
            'dr.Item("CategoryName")=

            'Dim dt As DataTable = getable()
            'Dim dr As DataTableReader = dt.CreateDataReader()
            'dt.Rows.Add(
            'dt.Load(dr)

            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 ='00000S^' order by category_name asc"
            If con1.State = Data.ConnectionState.Open Then
                con1.Close()
            End If
            Session("MainCat") = "00000S^"
            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("00000V>", gv1)
                End If
                If j = 1 Then

                    bottomCategory("00000V?", gv2)
                End If
                If j = 2 Then

                    bottomCategory("00000V@", gv3)
                End If
                If j = 3 Then

                    bottomCategory("00000VA", gv4)
                End If
                If j = 4 Then

                    bottomCategory("00000VB", gv5)
                End If
                If j = 5 Then
                    bottomCategory("00000VC", gv6)
                End If
                If j = 6 Then

                    bottomCategory("00000VD", gv7)
                End If
                If j = 7 Then

                    bottomCategory("00000VE", gv8)
                End If
                If j = 8 Then

                    bottomCategory("00000VF", gv9)
                End If
                If j = 9 Then

                    bottomCategory("00000VG", gv10)
                End If
                If j = 10 Then

                    bottomCategory("00000VH", gv11)
                End If
                If j = 11 Then

                    bottomCategory("00000VI", gv12)
                End If
                If j = 12 Then

                    bottomCategory("00000VJ", gv13)
                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 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 gv13_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv13.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 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
