Imports System.Web.Configuration

Partial Public Class BrandList
  Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
      If WebConfigurationManager.AppSettings("strPage") = "BrandDetails" Then
        gvBrand.PageIndex = WebConfigurationManager.AppSettings("intListIndex")
      End If
      gvBrand.PageSize = WebConfigurationManager.AppSettings("PAGESIZE")
    End If
  End Sub
																	 
	Private Sub gvBrand_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvBrand.RowDataBound
		If e.Row.RowType = DataControlRowType.DataRow Then
			Dim btnDelete As LinkButton = CType(e.Row.Cells(e.Row.Cells.Count - 1).Controls(0), LinkButton)
			btnDelete.OnClientClick = String.Format("return confirm('Are you certain you want to delete brand {0} ?');", DirectCast(DirectCast(e.Row.Cells(0).Controls(0), System.Web.UI.Control), System.Web.UI.WebControls.HyperLink).Text)
		End If
	End Sub

	Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSearch.Click
		Dim s, strAnd As String
		If ddlStatus.SelectedValue > -1 Then
			s = "blnActive = " & ddlStatus.SelectedValue
			strAnd = " AND "
		End If
		If Trim(txtBrand.Text) <> "" Then
			s &= strAnd & "strBrand LIKE '%" & sqlDB.CleanString(txtBrand.Text) & "%'"
			strAnd = " AND "
		End If

		sdsBrand.FilterExpression = s
	End Sub

	Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAdd.Click
		Response.Redirect("BrandDetails.aspx")
	End Sub

	Protected Sub ddlStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ddlStatus.SelectedIndexChanged
		btnSearch_Click(sender, e)
	End Sub
End Class