Error: Subreport could not be shown

by rbellantoni 4/27/2010 7:12:00 AM

This frustrating error caused me quite a headache, however I can say that this error is caused only by a total of 3 possibilities.

1.) The report parameters that you are passing into the sub-report from the parent report are not correct. This is for BOTH RDL and RDLC's

2.) The subreport's ReportName property is not properly associating itself with the appropriate RDL/RDLC (Note: it must be the name of the report i.e. rptFakeReport, without the RDLC or RDL extension at the end), ALSO for both RDL and RDLC

3.) You are running the sub-report from a website that is not using a report server but instead running locally, meaning you are using an RDLC. If this is the case you need to do the follow:

This is in VB.NET but you need to add an event handler in the page load section of the page, this wires up your sub-report to your page so every time the sub-report is run this event fires, this basically gets the data you want in your subreport.

AddHandler RvFunctionSlipMaster.LocalReport.SubreportProcessing, AddressOf ItemsSubreportProcessingEventHandler

Next you create your method to handle the event and then set e.DataSources.Add to rebind your new datasource for the sub-report. You will also notice you have access to all the parameters passed into the sub-report through e.Parameters, this you can use to filter the dataset for your sub-report


 Private Sub ItemsSubreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)

        Dim functionID As Integer = CInt(e.Parameters("FunctionID").Values(0).ToString())

        Dim dsSubReport As DataSet = SqlHelper.ExecuteDataset(Global_asax.gSqlConStr, 60, "spRptGetFunctionItemsHistory", functionID)

        e.DataSources.Add(New ReportDataSource("ReportDataSet_spRptGetFunctionItems", dsSubReport.Tables(0)))

    End Sub



Listview Eval, Dateformat, and ShortDate

by ebarcza 4/23/2010 7:39:00 AM

Here's how to format a short date from an eval statement

<td><%# Eval("StartDate", "{0:d}")%></td>



SQL Function return table with all days in month

by ebarcza 4/8/2010 11:22:00 AM

CREATE FUNCTION [dbo].[GetDaysInMonth] (@CurrentDate datetime)
    Return table
RETURNS @DaysInMonthTable table
([ValidDate] [DateTime]

declare @BOM smallDateTime
declare @EOM smalldateTime
declare @tempDate smallDateTime
SET @BOM = dbo.StartOfMonth(@CurrentDate)
SET @EOM = DATEADD (mm , 1, dbo.StartOfMonth(@CurrentDate) ) - 1

 INSERT INTO @DaysInMonthTable (ValidDate)  
 SET @BOM = @BOM + 1   



usage =

Select * from dbo.GetDaysInMonth(GetDate())



C# ListView datakeys in ItemDataBound

by ebarcza 4/7/2010 10:25:00 AM

Here's how the DataKeys are set up in the list view control

<asp:ListView ID="lv" runat="server" OnItemDataBound="ItemDataBound" onsorting="lv_Sorting" DataKeyNames="ICECounterPartyID,CompanyID" onitemediting="lv_ItemEditing">


Here's how to access them in the ItemDataBound Event:

int CompanyID = (int)lv.DataKeys[listView.EditIndex][1];



ListView vs Gridview

by rbellantoni 4/7/2010 8:43:00 AM

Some people may be wondering what is the difference is between a ListView and a GridView. In my opinion, the ListView is a much better tool in regards to displaying and manipulating data. With the ListView you use templates to design the different views. The first template is the with this template you can dictate where you want your datarows to show up and how you want your data laid out here is an example:

<asp:ListView ID="lvProducerPools" runat="server" onitemdatabound="lvProducerPools_ItemDataBound" onitemcommand="lvProducerPools_ItemCommand" DataKeyNames="PoolID,Locked_flag">
<div style="float:left;width: 1000px;overflow-x:auto;overflow-y:hidden;padding-top:5px; padding-bottom:15px;">
<table cellpadding="0" cellspacing="0" style="table-layout:fixed;height:18px;font-size:10pt;">
<tr style="height:18px;" id="itemPlaceholder" runat="server" />
<td id="poolLInk" style="width:175px;height:18px;background-color:#cdcdcd;border-right:1px gray groove; padding: 2px;" runat="server">
<asp:LinkButton ID="lnkLoadPool" runat="server"> <%# Eval("PoolName")%></asp:LinkButton>
<asp:Image ToolTip="Deals in this allocation have been locked" ID="imgLock" runat="server" Visible='<%# Eval("Locked_flag")%>' ImageUrl="~/images/lock.gif" />
<asp:Label BorderColor="#8c9bad" BackColor="White" Font-Bold="true" BorderStyle="Double" BorderWidth="2px" ForeColor="Black" Font-Size="10px" ID="lblImbalance" runat="server" Text='<%# Eval("TLBalance")%>' >
<td id="poolLInk" style="background-color:#cdcdcd;border-right:1px gray groove; padding: 4px;" runat="server">

The ID for "itemPlaceHolder" is not by accident, this is the identifier row where your itemtemplate rows will be bound. The advantage to this is that you have FULL control of how the html is rendered from your datasource. Whereas in a gridview your stuck with the table column design of the layout. Additionally you can use the datapager control inside of the template to enable paging, which does not work with the Gridview Control.




Force SSL Redirect HTTP to HTTPS

by rbellantoni 4/6/2010 6:08:00 AM

Put this code in your Application_BeginRequest in the global asax file:



If HttpContext.Current.Request.IsSecureConnection.Equals(False) Then

Response.Redirect(("https://" & Request.ServerVariables("HTTP_HOST")) + HttpContext.Current.Request.RawUrl)

End If




if (HttpContext.Current.Request.IsSecureConnection.Equals(false))


Response.Redirect("https://" + Request.ServerVariables["HTTP_HOST"] + HttpContext.Current.Request.RawUrl);




Calling wcf service from Winform the operation has timed out

by ebarcza 4/1/2010 11:47:00 AM

I created a basic WCF service in a C# .NET web site. I was trying to connect to it via a web reference from a Winforms app with no luck. I kept on getting an error message "the operation has timed out"

The fix - use basic binding in the endpoint configuration

<service behaviorConfiguration="MyBehavior" name="MyNameSpace">
    <endpoint address="basic" binding="basicHttpBinding" contract="MyContract"><BR>
      <dns value="localhost" /><BR>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /><BR>

Voila - no more timeout - Give it a swirl!

Tags: , ,


Powered by BlogEngine.NET
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail


<<  July 2017  >>

View posts in large calendar

Recent comments



The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017

Sign in