Public Class TeamSetup
   Inherits System.Web.UI.Page

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      Try
         If Not Me.IsPostBack Then
            Dim s As Integer = 1
         Else
            Dim s As Integer = 1
         End If
      Catch ex As Exception
         lblMessage.Text = ex.Message & "<BR/>" & ex.StackTrace
      End Try
   End Sub

   Private Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRenderComplete
      Dim imgLoading As WebControls.Image
      imgLoading = Page.Master.FindControl("imgLoading")
      imgLoading.CssClass = "invisible"
   End Sub

   'Protected Sub btnNew_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnNew.Click
   '   Response.Redirect("TeamSetupEdit.aspx")
   'End Sub

   Protected Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click

      teamSetupGridviewDataSource.FilterExpression = "1=1"

      If ddlJobRole.SelectedIndex > 0 Then
         teamSetupGridviewDataSource.FilterExpression &= " AND QuestionnaireID = " & ddlJobRole.SelectedValue
      End If

      If ddlUser.SelectedIndex > 0 Then
         teamSetupGridviewDataSource.FilterExpression &= " AND UserID = " & ddlUser.SelectedValue
      End If

      If ddlManager.SelectedIndex > 0 Then
         teamSetupGridviewDataSource.FilterExpression &= " AND ManagerID = " & ddlManager.SelectedValue
      End If
   End Sub

   Protected Sub btnExport_Click(sender As Object, e As EventArgs) Handles btnExport.Click
      Response.Clear()
      Response.Buffer = True
      Response.ContentType = "application/vnd.ms-excel"
      Response.Charset = ""
      Response.AddHeader("Content-Disposition", _
       "attachment;filename=TeamSetup_" & Session.Item("USER")!strUserName.Replace(" ", "") & "_" & Date.Today.ToString("yyyyMMdd") & ".xls")
      Me.EnableViewState = False

      Dim oStringWriter As New System.IO.StringWriter()
      Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
      Dim frm As HtmlForm = New HtmlForm()
      Me.Controls.Add(frm)
      frm.Controls.Add(teamSetupGridview)
      frm.RenderControl(oHtmlTextWriter)
      Response.Write(oStringWriter.ToString())

      Response.End()
   End Sub
End Class