CHAPTER 9 RENDERING REPORTS FROM .NET APPLICATIONS
ArrayList aList = new ArrayList();
pvs = rp.ValidValues;
foreach (ValidValue pv in pvs)
{
aList.Add(new ComboItem(pv.Label,pv.Value));
}
//Bind list items to combo box
a.DataSource = aList;
a.DisplayMember="Display";
a.ValueMember="Value"; }
So, for each ReportParameter, you see whether any ValidValues properties exist. If they do exist, you
loop through them, adding each item to the combo box. Because you want to retrieve the display name
and the actual value for each item in the combo box, you have to create a combo box item class and bind
the objects to the combo box. Listing 9-8 shows the full GetParameters_Load event method, and Listing
9-9 shows the ComboItem class.
Knowing something about our report, we already know that some of the parameters are dependent
on other parameter values. If we simply run through the list of ValidValues for each parameter, some of
them will include no values because of this dependency. We can use this previous knowledge to pass in a
bit of information to the getItemParameters method. We will place one ParameterValue item in the
values array so we can retrieve some valid values for all of our other parameters.
We also need to retrieve the display name and the value selected of each item in the combo boxes.
We are also going to create a combo box item class to handle this by binding each combo item to the
combo box. Listing 9-8 shows the GetParameters_Load event and Listing 9-9 shows the ComboItem
class.
Note We are populating the rest of the parameters based on just one possible Service Year value. Since, in
some reports, the other parameter valid values might change, you could include an overridden event method that
would refresh each of the other parameter values anytime the year was changed.
Listing 9-8. Get Report Parameters and Possible Values and Display Them in Combo Boxes
private void GetParameters_Load(object sender, EventArgs e)
{
rs = new ReportingService2010();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
bool forRendering = true;
string historyID = null;
ParameterValue[] values = new ParameterValue[1];
DataSourceCredentials[] credentials = null;
ItemParameter[] parametersSSRS = null;
ValidValue[] pvs = null;
int x = 5;
int y = 30;