Hi,
how to pass multi select paramteres in asp.net..
I will have 3 Paramters i.e., on my webform user will select
*. startdate and enddate
*. Division
*. Department
If user had selected one division (ex: Fin) and one department(ex: Finance) then i would not have any problem.
But here user can select multiple division (ex: Fin,IT,HR) and multiple departments (ex: Finance,Information.Tech,Human Resources) then how to pass this multiple paramters in asp.net?
I have sample code which i used in previous project for passing single parameters..below is code,
Below am passing Date (Period), ProjectNo and SupplierCode (Here user can select only one Project No and SupplierCode).
Try
If ConState = False Then
Connect()
End If
Dim ConnInfo As New ConnectionInfo
With ConnInfo
.ServerName = mOleDB.strServerName
.DatabaseName = mOleDB.strDBName
.UserID = mOleDB.strUsrName
.Password = mOleDB.strUsrPwd
End With
' Declare variables needed to pass the parameters
' to the viewer control.
Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim discreteVal As New ParameterDiscreteValue
Dim rangeVal As New ParameterRangeValue
' Set the name of the parameter field, this must match a
' parameter in the report. (Date Parameter)
paramField.ParameterFieldName = "Period"
' Set the start and end values of the range and pass it to the 'parameter.
rangeVal.StartValue = ClosedReport.StartDate
rangeVal.EndValue = ClosedReport.EndDate
paramField.CurrentValues.Add(rangeVal)
' Add the first parameter to the parameter fields collection.
paramFields.Add(paramField)
' The second parameter is a discrete value. The paramField variable
' is set to new so the previous settings will not be overwritten.
paramField = New ParameterField
'Set the name of the parameter field, this must match a
' parameter in the report.
paramField.ParameterFieldName = "ProjectNo"
' Set the first discrete value and pass it to the parameter based on conditions.
If ClosedReport.ProjectNo <> "" Then
discreteVal.Value = ClosedReport.ProjectNo
Else
discreteVal.Value = "*"
End If
paramField.CurrentValues.Add(discreteVal)
' Add the parameter to the parameter fields collection.
paramFields.Add(paramField)
' Set the second discrete value and pass it to the parameter.
' The discreteVal variable is set to new so the previous settings
' will not be overwritten.
paramField = New ParameterField
'Set the name of the parameter field, this must match a
' parameter in the report.
paramField.ParameterFieldName = "SupplierCode"
discreteVal = New ParameterDiscreteValue
' Set the second discrete value and pass it to the parameter based on conditions.
If ClosedReport.SupplierCode <> "" Then
discreteVal.Value = ClosedReport.SupplierCode
Else
discreteVal.Value = "*"
End If
paramField.CurrentValues.Add(discreteVal)
' Add the parameter to the parameter fields collection.
paramFields.Add(paramField)
' Set the parameter fields collection into the viewer control.
CrystalReportViewer_SuppProjOpen.ParameterFieldInfo = paramFields
CrystalReportViewer_SuppProjOpen.ReportSource = crReportDocument
For Each cnInfo As TableLogOnInfo In Me.CrystalReportViewer_SuppProjOpen.LogOnInfo
cnInfo.ConnectionInfo = ConnInfo
Next
'Me.CrystalReportViewer_SuppProjClosed.RefreshReport()
CrystalReportViewer_SuppProjOpen.Visible = True
Catch err As System.Exception
MessageBox.Show(err.Message, "System error!", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Thanks to help.