Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created two aspx pages where first page contains a dropDownList control :
XML
<asp:DropDownList ID="ddlGroupBy" runat="server" >
                <asp:ListItem Selected="True" Value="Department" Text="Department Wise" />
                <asp:ListItem Value="Grade" Text="Grade Wise" />
                <asp:ListItem Value="Team" Text="Team Wise" />
                <asp:ListItem Value="Category" Text="Category Wise" />
                <asp:ListItem Value="Location" Text="Location Wise" />
            </asp:DropDownList>

And a button control which redirect me to second page wehen I click it.
Second page has CrystalReportViewerControl which displays .rpt files records.
I have also taken a CrystalReport.rpt file and designed it. In this file Recoeds will be grouped by default “Department Wise”. But I don’t know how to change the Group Name Fields (which is ‘Department’ by default) if user change the dropDownControl’s items appropriately.
Posted
Updated 9-Jun-12 2:58am
v4

1 solution

You can use Formula Field to change GroupName based on DropDown selection .

Thank You

You Can follow this steps :
1.Save selected value of dropdown in variable 
2.Assgin to Querystring in  Response.Redirect
3.Retrive from Query string in second Page 
4.Assign retrived value to formula field  
5.Finally In Crystal Report ,  Check in If Else and assign value to group name accordingly


Here I have taken One DropDown and Button , on button click , seconf Page will get called.

To Save selected value in variable in first page :
VB
Dim strGroupType As String
strGroupType = ddlInput.SelectedItem.Text.ToString()
Response.Redirect("secondPage.aspx?GroupName=" + strGroupType)


In Second Page , To retrive value from QueryString
VB
Dim strGroupName = Request.QueryString("GroupName")


To Set in Fornula Field
VB
Dim strFormulas(1) As String '
strFormulas(0) = strGroupName.ToString()
rptViewer.SetFormaulas = strFormulas

Finally In Crystal Report :
VB
If {(strGroupName)= "IT"} Then
        grpName := "IT"
           ElseIf {(strGroupName)= "Purchase"} Then
        grpName := "Purchase"
       Else
        grpName := "Department"  'This is default
 
Share this answer
 
v2
Comments
Dinesh Ambaliya 12-Jun-12 5:16am    
But how! Can you give me any idea please!
Thank you for your help!
Dinesh Ambaliya 14-Jun-12 0:44am    
I have tried what you have said above like this:
Stored dropDownList’s value in queryString and this value provided to the parameter ‘?grpName’ which is created in the rpt file using ReportDocument.setParameter(“?grpName”,dropDownListValue);
And then written code in the group selection editor as follow:
if({?grpGroup} = "Grade") then
GroupName() = GroupName ({Employees.Grade});
else
GroupName() = GroupName ({Employees.Department});
I know that the code is not correct but it can be useful to understand my problem
By the way thank you again for your try.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900