Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Passing DropDownList Values To Crystal Reports Post Reply Post New Topic
Author Message
hmmmmmm
Newbie
Newbie


Joined: 11 Dec 2010
Online Status: Offline
Posts: 7
Quote hmmmmmm Replybullet Topic: Passing DropDownList Values To Crystal Reports
     Posted: 11 Dec 2010 at 11:38pm
SourcePage.aspx (Two DropDownLists & Submit Button)

<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
<asp:ListItem>Three</asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem>ABC</asp:ListItem>
<asp:ListItem>DEF</asp:ListItem>
<asp:ListItem>GHI</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btn1" runat="server" onclick="btnsubmit_Click" 
Text="Submit" />

Srouce.aspx.cs

protected void btnsubmit_Click(object sender, EventArgs e)
{
Server.Transfer("Target.aspx");
}


Target.aspx

// Report Viewer


Target.asp.cs

protected void Page_Load(object sender, EventArgs e)
    {
        if (PreviousPage != null)
        {
            DropDownList DDList1 = PreviousPage.FindControl("DropDownList1") as DropDownList;
DropDownList DDList2 = PreviousPage.FindControl("DropDownList2") as DropDownList;

if (DDList1.SelectedItem.Text=="One" && DDList2.SelectedItem.Text=="ABC"
)
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load("Report Path");

ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

crParameterDiscreteValue.Value = DDList1.SelectedItem.Text + DDList2.SelectedItem.Text
;
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["MyParameter"];
crParameterValues = crParameterFieldDefinition.CurrentValues;

crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

CrystalReportViewer1.ReportSource = cryRpt;

}

        }
    }


Works Fine For One DropDownList. But Not For Two DropDownList Values.

Can Any Body Clarify Where Problem Exists????

Regards






Edited by hmmmmmm - 11 Dec 2010 at 11:39pm
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum