Formula field on crystal report of asp.net as hyperlink

Dani AI

Generated

Two practical ways to get the result described (click the amount and show a subreport filtered by project and amount). asked for clarification earlier; below are tested patterns and the common pitfalls to watch for.

First (simpler inside Crystal Designer): use an on‑demand subreport and link fields. Insert the subreport as "On‑demand", create parameter(s) in the subreport, then in the main report use "Change Subreport Links..." to link the main report fields (ProjectNo and Amount) to the subreport parameters. In the subreport's record selection use those parameters, for example:

{Transactions.ProjectNo} = {?Pm-ProjectNo}
AND
{Transactions.UtilAmt} = {?Pm-UtilAmt}

That keeps everything in one .rpt; the viewer will show the on‑demand link which opens the detail subreport for the clicked row.

Second (if you want the number itself to look/click like a link): make the amount field a hyperlink to an ASPX page that loads the detail/subreport. In Crystal format for the field pick Hyperlink -> "A website on the Internet" and build a URL formula such as:

"ViewDetails.aspx?ProjectNo=" & ToText({Main.ProjectNo},0,"") & "&Amount=" & ToText({Main.UtilAmt},2,"")

On the ASPX page load the detail report and set parameters and database logon programmatically. Example C# snippets you can adapt:

ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("~/Reports/MainReport.rpt"));

ConnectionInfo ci = new ConnectionInfo { ServerName=server, DatabaseName=db, UserID=user, Password=pw };
foreach (Table t in rpt.Database.Tables) { var tli = t.LogOnInfo; tli.ConnectionInfo = ci; t.ApplyLogOnInfo(tli); }
foreach (ReportDocument sr in rpt.Subreports) foreach (Table t in sr.Database.Tables) { var tli = t.LogOnInfo; tli.ConnectionInfo = ci; t.ApplyLogOnInfo(tli); }

rpt.SetParameterValue("ProjectNo", projectNo, "SubreportObjectName");
CrystalReportViewer1.ReportSource = rpt;

Troubleshooting notes: always set database logon for every subreport table, make sure parameter names/subreport object names match when calling SetParameterValue, avoid "Save Data with Report" when you expect fresh filtering, and avoid putting sensitive info in query strings (use session or a short token instead).

Recommended Answers

All 2 Replies

Formula field on crystal report of asp.net as hyperlink

What is your problem :-/

What is your problem :-/

when i click on report field den it should open subreport and i also want at d same time multiple parrameters should be pass to main report to sub report means subreport must shows those values which matches dat row--

means der r field like
project no utilizationamnt
41 1000
38 5000
den after click on 5000 subreport should open and dat subreport shows how dis utilization amount is used by transaction in detail for dat project no so project no also must be passed when click on dat amount

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.