You are on page 1of 4

Introduction This article demonstrates how to filter Crystal Report's data based on textbox value without logon prompt

using ASP. !T with C". #ere $ have created two web pages and a Crystal Report. %ne web page for a textbox value and a button and another web page for displaying Crystal Reports. Problem with single web page &y using a single webpage' the Crystal Report's options export' print' (oom' etc. will not wor) properly' so this article can shows how to do that with two web pages for proper functionality without a logon prompt. Database for this sample $ have used the database name *!mp+etails*' in that the table will be an *empno* and other columns as follows,

Creating first web page Create the first web page for the Textbox value for filtering the Crystal Report data. $n this add a textbox and a button. See the following designer code, -html xmlns.*http,//www.w0.org/1222/xhtml*3 -head runat.*server*3 -title3., 4ilter The +ata #ere ,.-/title3 -/head3 -body3 -form id.*form1* runat.*server*3 -div style.*text5align,center6 padding,78px 8px 78px 8px6*3 -h134iltering Crystal Report +ata based on Text&ox 9alue without :ogon Promt-/h13 !nter +esignation , -asp,Text&ox $+.*Txt+esig* runat.*server*3-/asp,Text&ox3-br /3

-asp,&utton $+.*&tnReport* runat.*server* Text.*Show Report* onclic).*&tnReport;Clic)* /3 -/div3 -/form3 -/body3 -/html3 ow write the code in the button clic) event to ta)e a textbox value in the session and redirect to another page. The code will be as shown below, protected void &tnReport;Clic)<ob=ect sender' !ventArgs e> ? Session@*A%&*B . Txt+esig.Text6 Response.Redirect<*ReportPage.aspx*>6 C Then create the Crystal Reports report. Creating Crystal Report 4irst create the Crystal Reports report with Create ew Connection 53 %:! +&<A+%> 53 Select SD: Server provider 53 !nter Server ame' Eser ame' Password' +atabase ame 53 add table <$ used !mp table> 53 add columns <$ used !mp o' ame' Aob' Sal' +eptno> 53 4inish. ow 4ield !xplorer 53 Parameter 4ields 53 Right5clic) 53 Clic) %F. ew 53 !nter details li)e below 53

ow select Crystal Reports 53 Crystal Reports Genu 53 Report 53 Select !xpertHIJ 53 select emp.=ob <Khich was filtering column> li)e below,

Clic) %F 53 in first drop down list select *is eLual to* then select Parameter field ?MA%&C then clic) %F as shown below,

Then create the second web page. Creating second web page Create the second web page and add a CrystalReport9iewer and Source as shown in the following code, -html xmlns.*http,//www.w0.org/1222/xhtml*3 -head runat.*server*3 -title3., See The Report #ere ,.-/title3 -/head3 -body3 -form id.*form1* runat.*server*3 -div style.*text5align,center6 padding,78px 8px 78px 8px6*3 -h13See the Report Khich was 4iltered &y the value of Text&ox-/h13-br /3 -CR,CrystalReport9iewer $+.*CrystalReport9iewer1* runat.*server*

se*

Auto+ata&ind.*True* +isplayNroupTree.*4alse* !nable+atabase:ogonPrompt.*4al

!nableParameterPrompt.*4alse* #eight.*1802px* ReportSource$+.*CrystalReportSource1* ReuseParameter9alues%nRefresh.*True* Kidth.*OO0px* /3 -CR,CrystalReportSource $+.*CrystalReportSource1* runat.*server*3 -Report 4ile ame.*!mpReport.rpt*3 -/Report3 -/CR,CrystalReportSource3 -/div3 -/form3 -/body3 -/html3 Then write this code in page load event li)e in the following. amespaces using Crystal+ecisions.Shared6 using Crystal+ecisions.CrystalReports.!ngine6 Code protected void Page;:oad<ob=ect sender' !ventArgs e> ? Report+ocument rd . new Report+ocument<>6 rd.:oad<*4ull Path of Pour ReportQ!mpReport.rpt*>6 rd.Set+atabase:ogon<*Eser ame*' *Password*' *Server ame*' *+atabase*>6 rd.SetParameter9alue<*A%&*' Session@*A%&*B>6 CrystalReport9iewer1.ReportSource . rd6 C 4inally &uild and run the first page6 provide input then clic) the button then it shows the report and all the options li)e export' print' etc. will wor) normally. !n=oy Programming. Summary $n this article' $ discussed how we can filter the Crystal Report data based on a textbox value without logon prompt. As $ discussed previously the problem with Crystal Reports controls will be solved through this method of creating two web pages. And also $ have used a simple session element creation and pass this value from one page to another page.

You might also like