Purchase your Section 508 Compliance Support guide now!

Purchase your Section 508 Compliance Support guide now!

CognosSDK.cs -- Parameters (optional)

Here is a detailed example of getting a report’s parameter collection and dynamically generating an ASP.NET control for each of the Report Studio report’s parameters.  This code is for discussion purposes only, and our sample ASP.NET web solution will not use this approach.

 

It is important to note that you must use a standard naming convention for your prompt page controls in Report Studio.  This Cognos SDK code also is only looking for Report Studio prompt pages that contain a ListBox, Calendar, or TextBox prompt control.

 

If you want to discuss more about the Cognos SDK then be sure to visit http://cognos8helpsdkguide.blogspot.com/2007/11/bi-centre-sdk-guide.html.

 

 

private void GetPromptControls(asynchDetail[] _paramDetail)

            {

                  baseParameter[] _num = new baseParameter[]{};

                  tableDynamic = new Table();

                 

                  if (_paramDetail != null)

                       

                        for (int j=0; j<_paramDetail.Length; j++)

 

                              if (_paramDetail[j] is asynchDetailParameters)

                              {

                                    _num = ((asynchDetailParameters)_paramDetail[j]).parameters;                                                

 

                                    for (int x = 0; x < _num.Length; x++)

                                    {

                                          #region "Add TextBox prompt controls"

                                          if (_num[x].name.Substring(0,3) == "txt")

                                          {

                                                //tr1 for label

                                                TableRow tr1 = new TableRow();  // Create column 1 

                                                TableCell td1 = new TableCell();  // Create a label control dynamically 

                                               

                                                Label lbl = new Label();

                                                lbl.ID = String.Format("lbl{0}",x);

                                                lbl.Text = _num[x].name.Substring(3).ToString();

                                                lbl.Font.Size = 10;

                                               

                                                td1.Controls.Add(lbl);    // Create column 2                                                                                     

                                               

                                                //tr2 for control

                                                TableRow tr2 = new TableRow();  // Create column 1 

                                                TableCell td2 = new TableCell();  // Create a label control dynamically 

                                         

                                                TextBox txtBox = new TextBox();                                              

                                                //txtBox.ID = String.Format("txtBox{0}", x);

                                                txtBox.ID = _num[x].name.ToString();

                                                td2.Controls.Add(txtBox);  // Add cell to the row

 

                                                // Add control to the table cell                                             

                                                tr1.Cells.Add(td1); 

                                                tr2.Cells.Add(td2);  // Add row to the table. 

                                                tableDynamic.Rows.Add(tr1);

                                                tableDynamic.Rows.Add(tr2);

                             

                                                phPrompts.Controls.Add(tableDynamic);

                                          }