Imports System
Imports System.Data
Imports System.Data.SqlClient
Partial Class category1_Packaging_ShippingProducts
    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 ='00000T3' order by category_name asc"
            Session("MainCat") = "00000T3"
            If con1.State = Data.ConnectionState.Open Then
                con1.Close()
            End If
            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
                Session("mcat") = Nothing
                If j = 0 Then
                    bottomCategory(catid, gv2)
                End If
                If j = 1 Then
                    bottomCategory(catid, gv11)

                End If
                If j = 2 Then
                    bottomCategory(catid, gv3)

                End If

            Next

            con1.Close()

        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 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
End Class
