R
Rob Wire
For the code below, how could I add an item in the drop
down lists for both company and location to be an "All"
selection that would send to the stored proc.
spRptAttachments a value of "%" so that it would bring
back all attachments at all companies or all locations at
a company? Thank you, Rob.
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim cmd As System.Data.SqlClient.SqlCommand
cmd = New System.Data.SqlClient.SqlCommand
("Web_CompanyList", Me.SqlConnection1)
cmd.CommandType = CommandType.StoredProcedure
Me.SqlConnection1.Open()
Dim myDataReader As
System.Data.Sqlclient.SqlDataReader = cmd.ExecuteReader
(CommandBehavior.CloseConnection)
ddlCompany.DataSource = myDataReader
ddlCompany.DataValueField = "CompanyID"
ddlCompany.DataTextField = "CompanyName"
ddlCompany.DataBind()
ddlCompany_SelectedIndexChanged(Nothing,
Nothing)
End If
End Sub
Private Sub ddlCompany_SelectedIndexChanged(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles ddlCompany.SelectedIndexChanged
Dim param As System.Data.SqlClient.SqlParameter
Dim cmd As System.Data.SqlClient.SqlCommand
Dim intCompanyID As Integer
cmd = New System.Data.SqlClient.SqlCommand
("WEB_GetLocationFromCompanyID", Me.SqlConnection1)
cmd.CommandType = CommandType.StoredProcedure
param = cmd.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@CompanyID",
SqlDbType.Int))
param.Direction = ParameterDirection.Input
' ********Selected Value of Option List*******
param.Value = ddlCompany.Items
(ddlCompany.SelectedIndex).Value
Me.SqlConnection1.Open()
Dim myDataReader As
System.Data.Sqlclient.SqlDataReader = cmd.ExecuteReader
(CommandBehavior.CloseConnection)
ddlLocation.DataSource = myDataReader
ddlLocation.DataValueField = "CompanyLocationID"
ddlLocation.DataTextField = "CoLo"
ddlLocation.DataBind()
End Sub
Private Sub btnSearch_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnSearch.Click
Dim prmDateFrom As
System.Data.SqlClient.SqlParameter
Dim prmCoID As System.Data.SqlClient.SqlParameter
Dim prmColo As System.Data.SqlClient.SqlParameter
Dim cmd As System.Data.SqlClient.SqlCommand
Dim intCompanyID As Integer
cmd = New System.Data.SqlClient.SqlCommand
("spRptAttachments", Me.SqlConnection1)
cmd.CommandType = CommandType.StoredProcedure
prmDateFrom = cmd.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@DateFrom",
SqlDbType.DateTime))
prmCoID = cmd.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@CompanyID",
SqlDbType.Int))
prmColo = cmd.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@CompanyLocationID",
SqlDbType.Int))
prmDateFrom.Direction = ParameterDirection.Input
prmCoID.Direction = ParameterDirection.Input
prmColo.Direction = ParameterDirection.Input
' ********Selected Value of Option List*******
prmDateFrom.Value = tbDateFrom.Text
prmCoID.Value = ddlCompany.Items
(ddlCompany.SelectedIndex).Value
prmColo.Value = ddlLocation.Items
(ddlLocation.SelectedIndex).Value
Me.SqlConnection1.Open()
Dim myDataReader As
System.Data.Sqlclient.SqlDataReader = cmd.ExecuteReader
(CommandBehavior.CloseConnection)
DataGrid1.DataSource = myDataReader
DataGrid1.DataBind()
End Sub
down lists for both company and location to be an "All"
selection that would send to the stored proc.
spRptAttachments a value of "%" so that it would bring
back all attachments at all companies or all locations at
a company? Thank you, Rob.
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim cmd As System.Data.SqlClient.SqlCommand
cmd = New System.Data.SqlClient.SqlCommand
("Web_CompanyList", Me.SqlConnection1)
cmd.CommandType = CommandType.StoredProcedure
Me.SqlConnection1.Open()
Dim myDataReader As
System.Data.Sqlclient.SqlDataReader = cmd.ExecuteReader
(CommandBehavior.CloseConnection)
ddlCompany.DataSource = myDataReader
ddlCompany.DataValueField = "CompanyID"
ddlCompany.DataTextField = "CompanyName"
ddlCompany.DataBind()
ddlCompany_SelectedIndexChanged(Nothing,
Nothing)
End If
End Sub
Private Sub ddlCompany_SelectedIndexChanged(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles ddlCompany.SelectedIndexChanged
Dim param As System.Data.SqlClient.SqlParameter
Dim cmd As System.Data.SqlClient.SqlCommand
Dim intCompanyID As Integer
cmd = New System.Data.SqlClient.SqlCommand
("WEB_GetLocationFromCompanyID", Me.SqlConnection1)
cmd.CommandType = CommandType.StoredProcedure
param = cmd.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@CompanyID",
SqlDbType.Int))
param.Direction = ParameterDirection.Input
' ********Selected Value of Option List*******
param.Value = ddlCompany.Items
(ddlCompany.SelectedIndex).Value
Me.SqlConnection1.Open()
Dim myDataReader As
System.Data.Sqlclient.SqlDataReader = cmd.ExecuteReader
(CommandBehavior.CloseConnection)
ddlLocation.DataSource = myDataReader
ddlLocation.DataValueField = "CompanyLocationID"
ddlLocation.DataTextField = "CoLo"
ddlLocation.DataBind()
End Sub
Private Sub btnSearch_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnSearch.Click
Dim prmDateFrom As
System.Data.SqlClient.SqlParameter
Dim prmCoID As System.Data.SqlClient.SqlParameter
Dim prmColo As System.Data.SqlClient.SqlParameter
Dim cmd As System.Data.SqlClient.SqlCommand
Dim intCompanyID As Integer
cmd = New System.Data.SqlClient.SqlCommand
("spRptAttachments", Me.SqlConnection1)
cmd.CommandType = CommandType.StoredProcedure
prmDateFrom = cmd.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@DateFrom",
SqlDbType.DateTime))
prmCoID = cmd.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@CompanyID",
SqlDbType.Int))
prmColo = cmd.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@CompanyLocationID",
SqlDbType.Int))
prmDateFrom.Direction = ParameterDirection.Input
prmCoID.Direction = ParameterDirection.Input
prmColo.Direction = ParameterDirection.Input
' ********Selected Value of Option List*******
prmDateFrom.Value = tbDateFrom.Text
prmCoID.Value = ddlCompany.Items
(ddlCompany.SelectedIndex).Value
prmColo.Value = ddlLocation.Items
(ddlLocation.SelectedIndex).Value
Me.SqlConnection1.Open()
Dim myDataReader As
System.Data.Sqlclient.SqlDataReader = cmd.ExecuteReader
(CommandBehavior.CloseConnection)
DataGrid1.DataSource = myDataReader
DataGrid1.DataBind()
End Sub