Databases Reference
In-Depth Information
VB
Dim parameters() As ReportParameter
parameters = _rs.GetReportParameters(reportItem.Path, Nothing, False, _
Nothing, Nothing)
The last piece of work to do is to create a user interface for your parameters. The ReportParameter
objects returned by Reporting Services contain information useful for creating a custom interface. Some
of the key properties include the parameter data type, prompt, and valid values. All of these can be used
to define your own interface. Finish your code by simply adding a label and text box to your form for
each ReportParameter . Following is the completed GetParameter click event code.
C#
private void btnParameters_Click(object sender, System.EventArgs e)
{
//return the list of parameters for the report item
ReportItem reportItem = (ReportItem)cboReports.SelectedItem;
ReportParameter[] parameters;
parameters = _rs.GetReportParameters(reportItem.Path, null, false, null,
null);
//add the parameters to the parameter list UI
int left = 10;
int top = 20;
foreach(ReportParameter parameter in parameters)
{
Label label = new Label();
TextBox textBox = new TextBox();
label.Text = parameter.Prompt;
label.Left = left;
label.Top = top;
textBox.Name = parameter.Name;
textBox.Text = parameter.DefaultValues[0];
textBox.Left = left + 150;
textBox.Top = top;
top +=25;
grpParamInfo.Controls.Add(label);
grpParamInfo.Controls.Add(textBox);
}
}
VB
Private Sub btnParameters_Click(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles btnParameters.Click
'return the list of parameters for the report item
Dim reportItem As ReportItem = CType(cboReports.SelectedItem, ReportItem)
Dim parameters() As ReportParameter
parameters = _rs.GetReportParameters(reportItem.Path, Nothing, _
Search WWH ::




Custom Search