Category Archives: ReportViewer

[RESOLVED] ReportViewer: Drillthrough caused whole page refreshed

I have a Reportviewer control linked to Report1.rdlc with a matrix with Drillthrough activiated.

When I click the "+" buttons to drill through, even I enclosed the control with Penal etc it still caused the whole page refreshed which is annoying. The same  Panel code works well on other ASP.net controls on page on running.

Is there anything I can do here ? Thanks

Check this.

 

But I have to stay at most cases Reportviewer doesn't works with partial page postbacks.

 

Morzel

[RESOLVED] Image loading problem with https.....

Hello,

               I am having problem with loading image with https in web application. when i am using http, then the image on page is loading fine but when i am doing the same thing with https then the image is not visible, it is not loading the image.........

              What is the problem with https?? Can any body tell me please. And what is the solution for it.......Please reply soon

          Thanks in advance.

In my application i am deploying reports which are created in SQL server 2005.

The issue is when i am using HTTP url then the images on my reports are displayed fine but when i switch to HTTPs url then the images are not displayed in my report. 

<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">I am using reportviewer control to display RDLC report. Report has an external image. The image path of external image is set from code behind using Request.Url.Host. So, it should take 'http' if url is given with http and 'https' when url is specified with https. </div>

<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Is there any other reason why its not displayed with https?</div> <div></div>

I am using reportviewer control to display RDLC report. Report has an external image. The image path of external image is set from code behind using Request.Url.Host. So, it should take 'http' if url is given with http and 'https' when url is specified with https. 

    Please help me out ..........


Hi alisha_waghmare,

(1)If you browser the image by uisng the https in the Ie, you can see it?

(2)Please check the current user have pass the sll certificate authentication to the server.

If the current user can pass the ssl certificate authentication, the images should be displayed on the report.

Basic logic in ASP.NET with C#

How would I print different things to the file being sent to the user's browser based on parameters? In PHP I would
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;"> <div style="font: normal normal normal 11px/normal verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; margin-bottom: 2px;" class="smallfont">Code:</div>

if (parameter == value)
    print("<b>" . value . "</b>");
</div>
Notice how I can print tags as well as text? I am using C# with ASP.NET and would like to achieve the same effect. I am trying:
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;"> <div style="font: normal normal normal 11px/normal verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; margin-bottom: 2px;" class="smallfont">Code:</div>
<script runat="server">
    protected void chooseReport()
    {
        if (ddlPage.SelectedValue == "1")
            Console.WriteLine("<LocalReport ReportPath=\"AutoFinance\\rdlc\\1.rdlc\" EnableExternalImages=\"True\"></LocalReport>");
        else if (ddlPage.SelectedValue == "2")
            Console.WriteLine("<LocalReport ReportPath=\"AutoFinance\\rdlc\\2.rdlc\" EnableExternalImages=\"True\"></LocalReport>");
        else if (ddlPage.SelectedValue == "3")
            Console.WriteLine("<LocalReport ReportPath=\"AutoFinance\\rdlc\\3.rdlc\" EnableExternalImages=\"True\"></LocalReport>");
        else
            Console.WriteLine("<LocalReport ReportPath=\"AutoFinance\\rdlc\\4.rdlc\" EnableExternalImages=\"True\"></LocalReport>");
    }
</script>
</div>
However this does not seem to work. I need the report source to be different based on the user's choice, how would I do this? I don't think writing code that is sent to the user's browser is done with Console.WriteLine, but I don't know how else to.

Also, in the .ASPX file, how would I incorporate a C# variable into the ASP/HTML formatting tags? For example, if the variable
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;"> <div style="font: normal normal normal 11px/normal verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; margin-bottom: 2px;" class="smallfont">Code:</div>
int id = 4;
</div>
then I want to be able to do something like
<div style="margin-right: 20px; margin-bottom: 20px; margin-left: 20px; margin-top: 5px;"> <div style="font: normal normal normal 11px/normal verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; margin-bottom: 2px;" class="smallfont">Code:</div>
<img src="4.jpg">
</div>
where the 4 from 4.jpg is determined by the variable id.

There are a couple of ways to approach this. If you really want full control, implement the Render event and write the output using the HtmlWriter.

However, that's overkill for the type of stuff you are asking. Just plop a Literal control onto your webform. Let's say, litText. And do:

litText.Text = String.Format("<b>{0}</b>", value);

or

litText.Text = "<b>" + value.ToString() + "</b>";

You can do the same thing with String.Format("<img src=\"{0}.jpg\">", number). Alternatively, you can use an Image control and just set it's ImageUrl property.

c# is object oriented.... so, to send users tag to users browser, control for localreport can be made..... but that would be tedious...

u can add following tag in the .aspx file

<asp:literal id="ltrlLocalReport" runat="server"/>

then, change code as,

 

<script runat="server">
    protected void chooseReport()
    {
       string reportTag="";
       int selectedPage = ddlPage.SelectedValue;
       if(selectedPage != 1 && selectedPage != 2 && selectedPage != 3)
       {
          selectedPage = 4
       }
       reportTag= "<LocalReport ReportPath=\"AutoFinance\\rdlc\\" + selectedPage.Tostring() + ".rdlc\"  EnableExternalImages=\"True\"></LocalReport>";

     ltrlLocalReport.value = reportTag;
    }
</script>

whatever string assigned to literal control is rendered to client browser. though this is not the standard way... and u should use more OO way

hope this helps...

 

The above method does not work since it will just print <LocalReport ..> into the HTML of the page (so it can be seen when View Source, i.e. IIS is not parsing it. I'm thinking of something like

 

protected void ddlPage_selectionChanged(object sender, EventArgs e) {
    LocalReport.ReportPath = ddlPage.SelectedValue + ".rdlc";
}

 

 

however when I run it I get the error

Compiler Error Message: CS0120: An object reference is required for the nonstatic field, method, or property 'Microsoft.Reporting.WebForms.ReportViewer.LocalReport.get'

What object does LocalReport belong to?

 

[RESOLVED] Page_Load not firing after Response.Redirect()

This is driving me bananas. I really hope someone can help - I've trawled the web, and not been able to find a solution.

Some background: I am developing a data heavy application, in which there are a number of web pages which display data read from an SQL database. The data is displayed using a combination of ReportViewer, DataGrid and FormView controls. It is a fairly interactive application, and I am making use of ASP.NET AJAX to help things along. At any point in time, a page is displaying data for one entity (for the sake of example, lets say that the entity is an employee, and the page displays employee HR details). The user can navigate between employees using a number of different controls, including a dropdown list, and a search box. I also want to enable the user to search for an employee by supplying a query string in the URL. To minimise confusion, and ensure consistency, I do not want the URL to display query strings, as it is possible that the user may navigate to another employee, using page controls / AJAX, in which case, the URL would get out of sync with the page if the query string stayed visible.

In the final solution, I am using a combination of query string, Session variables, and Response.Redirect during Page_Load. Essentially, if a user supplies a query string, the Page_Load method detects it, sets a Session variable, and redirects to the same page, but without the query string. Following redirection, the Page_Load method detects that there is no longer a query string, and instead looks at the Session variable. If it is present, it initiates the search and populates the web page as appropriate.

The behaviour is inconsistent. Usually, if the query string is supplied via a hyperlink on a web page, it works fine. However, if the user types the query string into the address bar, it doesn't work. Looking further into it, I have found that when it doesn't work, it is because Page_Load does not get fired following the Response.Redirect.

Here is a heavily simplified example, which reproduces the problem for me:

Redirect.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Redirect.aspx.cs" Inherits="Redirect" EnableEventValidation="false" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">
    <title>Untitled Page</title></head><body>
    <form id="form1" runat="server">
        <div>
            Value:
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
            <a href="Redirect.aspx?q=test1">Redirect.aspx?q=test1</a><br />
            <a href="Redirect.aspx?q=test2">Redirect.aspx?q=test2</a><br />
        </div>
    </form></body></html> 

Redirect.aspx.cs:

public partial class Redirect : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e) {
        if (!IsPostBack)
            if (Request.QueryString.Count > 0 && !string.IsNullOrEmpty(Request.QueryString["q"])) {
                Session["q"] = Request.QueryString["q"];
                Response.Redirect(Request.Url.AbsolutePath, false);
            }
            else
                if (Session["q"] != null)
                    Label1.Text = Session["q"].ToString();
                else
                    Label1.Text = "(null)";    }

}

When either of the hyperlinks on the page is clicked, the label will be correctly set to the value of the query string. However, if the query string is typed into the address bar it is not.

More frustratingly, I find that this behaviour only occurs in either IE6 or IE7. Everything works perfectly in Firefox. Also, if I use cookieless session state, (cookieless="false" in web.config, mode="stateServer"), the code works fine in IE - but this is also not what I want, since the URL now has session information encoded in it, which is confusing to the user.

So it appears to me that the whole problem boils down to IE's handling of cookies - I've no idea what to do about this. As far as I can tell, all the IE browsers I have tried this on are at "factory standard" settings - which they have to be for my broad user group.

A few other comments relating to ideas I've seen elsewhere: I'm not using a web garden (max number of worker processes = 1). There are no underscore characters in the site name / URL.

Any ideas would be very gratefully received.

Nick.

Hi,

Add these lines to your page load event, Actually IE does a lot of client side caching, and would not retrieve a page which is in the current cache.

 

Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ExpiresAbsolute = DateTime.Now.AddMonths(-1);
  

FANTASTIC! THANKYOU!

Finally - a solution that works! And in the context of my application, client side caching is a waste of time, since the user will very rarely view the same information twice.

You beauty.

Very powerful solution after a very long search :) , thanks so much

[RESOLVED] Repeating same RDL file on same ReportViewer conrtol>>>URGENT>>>URGETNT

Hi All,

I am trying to display a rdl file multiple times on a single reportviewer control in asp.net.

Actually I have an rdl stub which displays monthly data and I want to repeat same rdl for each selected month.

Suppose If I select month January to March then I want to display 3 reports for each month on same reportviewer asp.net control.

I need this solution urgently. plz reply ASAP if you knows the solution.

An example will be highlyl appreciated.

Regards,

Mehar

Anyone plz

You can create the report viewer control dynamically and bind the data.

I want to use single reportviewer and to display multiple stubs month wise.

Can I use subreport for this purpose ?

If its possible then how can I programitically use subreport ?

 

Regards,

Mehar

Why do you required this apporach..

You somply group by your report data by month and year also add page breack with group by so you will get montly data in new page. So one month has more then 1 page data then it add new page but when new month comes again it starts with new page.

 

Hi Amit,

In my rdl file I have three DataSet, each dataset is getting data from a single table which is the requirement of the report. Currently months are stored in DBas 1,2,3,...12

I am new to SSRS reports development can you help me how I can group them in RDL and how to add page breaks.

One of my senario is that suppose if use selects From and To as Jan - March then there will be 4 reports, 3 for each month and 4th will be the summary of 3 months.

I will highly appreciate if you build a small example for me or some reference links.

 

Regards,

Mehar