I am designing an MVC application using ReportViewerForMVC. This is my controller code:
ReportViewer rp = new ReportViewer();
rp.ProcessingMode = ProcessingMode.Local;
rp.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath)
+ #"Report/sampleFile.rdlc";
ViewBag.ReportViewer = rp;
This is my View:
#using ReportViewerForMvc
#Html.ReportViewer(ViewBag.ReportViewerMicrosoft.Reporting.WebForms.ReportViewer)
The iframe shows but i get this message:
A data source instance has not been supplied for the data source 'DataSet1'.
as my output for the report section. I thought i specified my data source when designing my .rdlc file.
Again, i want to ask if i create a datatable with a where clause having parameter, how can i specify the value in my controller.
I have searched online and i'm not getting any useful. Can anyone please help me out?
The report viewer has no DataSource. If you like using designer view like myself, you could start by creating a dataset and adding a dataAdapter which will automatically add a dataTable. The dataSource can be set like this:
DataSet1 ds = new DataSet1();
TableAdapter1 ta = new TableAdapter1();
ta.Fill(ds.Table[0]);
ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSet";
rds.Value = ds.Table[0];
rp.LocalReport.DataSources.Clear();
rp.LocalReport.DataSources.Add(rds);
rp.LocalReport.Refresh();
As simple as that...
Change the following in View
#Html.ReportViewer(ViewBag.ReportViewerMicrosoft.Reporting.WebForms.ReportViewer)
to
#Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer)
Related
I have a table on my Telerik report where I want to pass parameters with the table's data source. I also have a report datasource with parameter but this does not help with the table's datasource and its parameter. Any help would be appreciated.
this.table1.DataSource = "GetLocationsData";
You have to set the available values source and most probably filters:
Telerik.Reporting.ReportParameter reportParameter1 = new Telerik.Reporting.ReportParameter();
this.csvDataSource1 = new Telerik.Reporting.CsvDataSource();
this.table1 = new Telerik.Reporting.Table();
this.csvDataSource1.Source = "id,text\r\n1,a\r\n2,b\r\n3,c";
this.table1.DataSource = this.csvDataSource1;
this.table1.Filters.Add(new Telerik.Reporting.Filter("= Fields.text", Telerik.Reporting.FilterOperator.Equal, "= Parameters.paramString.Value"));
reportParameter1.AvailableValues.DataSource = this.csvDataSource1;
reportParameter1.AvailableValues.ValueMember = "=Fields.Text";
reportParameter1.Name = "paramString";
reportParameter1.Text = "String";
reportParameter1.Value = "a";
reportParameter1.Visible = true;
this.ReportParameters.Add(reportParameter1);
If this does not help you, you can have a look at the available reports that come with the installation - replace in the path below your Telerik Reporting version, mine is R3 2022. View Code (F7) on the report's designer.cs file:
C:\Program Files (x86)\Progress\Telerik Reporting R3 2022\Examples\CSharp\.NET Framework\ReportLibrary
Another option if you are stuck, is to create the report in the Visual Studio Designer and View the generated code (F7) on the yourreportname.designer.cs file.
If the report was created using the web report or standalone report designer you can import the report definition file (trdp, trdx, trbp) into Visual Studio (will be converted to type definition .cs file) first.
Reference:
https://docs.telerik.com/reporting/designing-reports/connecting-to-data/report-parameters/how-to-add-report-parameters
https://docs.telerik.com/reporting/designing-reports/connecting-to-data/report-parameters/overview
I am trying to make an asp.net mvc 5 app by this ASP.NET image upload guide.
I am curious about this part of the guide (on the photo here):
as I understand at that part I am supposed to write the code in my View (cshtml) page. (Cause before there was attaching js's and running scripts in "<"script">" tag)
How can I write such C# code in the View? Where am I wrong?
string cors_location = (new UriBuilder(Request.Url.AbsoluteUri) { Path = Url.Content("~/Content/cloudinary_cors.html") }).ToString();
C# code in a view generally belongs in a server side block like this ...
#{
string cors_location = (new UriBuilder(Request.Url.AbsoluteUri)
{ Path = Url.Content("~/Content/cloudinary_cors.html") }).ToString();
}
How can I write such C# code in the View? Where am I wrong?
Hi.
like this by adding the '#'sign
#{string cors_location = (new UriBuilder(Request.Url.AbsoluteUri) { Path = Url.Content("~/Content/cloudinary_cors.html") }).ToString();}
also please check http://www.asp.net/web-pages/overview/getting-started/introducing-razor-syntax-c
my server should get a link of uploaded file
To manage this You should do something like this:
create property in Your model class for eg.
public string ImgUrl {get;set;}
In Your View controller you should pass url value from view
Img.Url = "My Image Url passed from View";
and then save Your model to Db.
For more please check http://www.mikesdotnetting.com/article/259/asp-net-mvc-5-with-ef-6-working-with-files
Can someone show me how to add filters and how to freeze rows in excel using C1Excel(ComponentOne) and C#?
//step 1: create a new workbook
C1XLBook logBook = new C1XLBook();
XLSheet logSheet = logBook.Sheets[0];
I have created XLSheet, but no property to add filters.
You can create frozen rows using Frozen property as :
C1.C1Excel.XLSheet sheet = c1XLBook1.Sheets[0];
sheet.Rows.Frozen = 2;
However, currently creating filters are not supported in C1Excel.
Thanks,
Richa
I've created my first custom Umbraco 5.1 solution. At this point I have a content item ("homepage") with a custom template which has a custom partial macro on it. Now how do I load an entity using the Umbraco helper? I've tried adding several HiveId constructions using a Uri, however I keep getting the same error:
Parameter 'other' must be of type Guid to convert to a Guid CLR type, but it is 'Uri', with value: xxx
Macro partial:
#inherits PartialViewMacroPage
#using Umbraco.Cms.Web
#using Umbraco.Cms.Web.Macros
#using Umbraco.Framework
#{
//All these fail with the same error message...
//Based on name:
var p = Umbraco.GetContentById(
new HiveId(
new Uri("content://Homepage")));
//Based on path
var p = Umbraco.GetContentById(
new HiveId(
new Uri("content://p__nhibernate/v__guid/5a4abe489a2e47858bd2a0580180b683")));
//With custom Hive provider (I've added this using a custom tree/section and products show up, so the hive provider works)
var p = Umbraco.GetContentById(
new HiveId(
new Uri("custom://products/1")));
}
Why are you creating a Uri?
The HiveId accepts a string parameter which you can use instead. So does Umbraco.GetContentById(string id)
I am Umbraco 5 certified and we never used the Uri overload of the HiveId constructor.
var p = Umbraco.GetContentById("yourStringHiveIdHere"); //(string overload) or
var p = Umbraco.GetContentById(new HiveId("yourSringHiveIdHere")); // (HiveId overload)
Also where are you getting your HiveId from?
I need to modify the T4 template POCO.tt to retrieve the database schema from the EDMX file. I can see the schema stored in an EntitySet tag in the XML. However I cannot find the schema anywhere when using an EntitySet object.
Anyone know where I would find the database schema?
Thanks
UPDATE
I wrote up my findings on this in a blog post:
http://www.ninjanye.co.uk/2011/06/getting-schema-information-from-edmx.html
http://jnye.co/Posts/3/getting-schema-information-from-an-edmx-file-with-poco
I came across this same problem myself.
First you need to retrieve the EntityContainer from the Storage Model Content (edmx:StorageModels) section of the edmx file
At the top of the tt template (after the MetadataLoader is instantiated and the inputFile is declared) add the following code to get the Storage Model Content EntityContainer
StoreItemCollection sic;
loader.TryCreateStoreItemCollection(inputFile, out sic);
EntityContainer sicEntityContainer = sic.GetItems<EntityContainer>().First();
Then from within the foreach (var entity in ItemCollection.GetItems...) loop you can get the current schema with the following
EntitySet eset = sicEntityContainer.GetEntitySetByName(code.Escape(entity), true);
string schemaName = eset.MetadataProperties["Schema"].Value.ToString();
Note: You may have to repeat the get schema code for ComplexType properties lower down in the tt template
I think I misunderstood your question the first time. Have you examined the edmx schema for any clues?
According to this link: http://msdn.microsoft.com/en-us/library/cc982042.aspx
The schema for applications that
target the .NET Framework version 4 is
defined in the
Microsoft.Data.Entity.Design.Edmx_2.xsd
file. The schema for applications that
target the .NET Framework version 3.5
SP1 is defined in the
Microsoft.Data.Entity.Design.Edmx_1.xsd
file.
Those are in %VS100COMNTOOLS%\..\..\Xml\Schemas\ for VS 2010, and %VS90COMNTOOLS%\..\..\Xml\Schemas\ (the 3.5 only) for VS 2008
I'm working with EF6 and wanted to add a summary comment to the classes being generated by the t4 template. After hacking around for a while, I managed to do it by loading the EDMX file and using XPath to find what I needed.
var xmlContent = XDocument.Load(textTransform.Host.ResolvePath(inputFile));
var edmxNavigator = xmlContent.CreateNavigator();
XmlNamespaceManager nsMgr = new XmlNamespaceManager(edmxNavigator.NameTable);
nsMgr.AddNamespace("edmx", "http://schemas.microsoft.com/ado/2009/11/edmx");
nsMgr.AddNamespace("store", "http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator");
nsMgr.AddNamespace("ssdl", "http://schemas.microsoft.com/ado/2009/11/edm/ssdl");
nsMgr.AddNamespace("cs", "http://schemas.microsoft.com/ado/2009/11/mapping/cs");
//This is the loop that came with the default template
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
{
fileManager.StartNewFile(entity.Name + ".cs");
BeginNamespace(code);
var mappingAttribute = edmxNavigator.SelectSingleNode("/edmx:Edmx/edmx:Runtime/edmx:Mappings/cs:Mapping/cs:EntityContainerMapping/cs:EntitySetMapping/cs:EntityTypeMapping[#TypeName=\"" + entity.FullName + "\"]/cs:MappingFragment/#StoreEntitySet", nsMgr);
var entitySet = edmxNavigator.SelectSingleNode("/edmx:Edmx/edmx:Runtime/edmx:StorageModels/ssdl:Schema/ssdl:EntityContainer/ssdl:EntitySet[#Name=\"" + mappingAttribute.Value + "\"]", nsMgr);
var actualTableName = (entitySet.SelectSingleNode("#Table") ?? entitySet.SelectSingleNode("#Name")).Value;
var actualSchemaName = (entitySet.SelectSingleNode("#Schema", nsMgr) ?? entitySet.SelectSingleNode("#store:Schema", nsMgr)).Value;
#>
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
/// <summary>
/// Database Object: <#=actualSchemaName#>.<#=actualTableName#>
/// </summary>
<#=codeStringGenerator.EntityClassOpening(entity)#>
See http://brewdawg.github.io/Tiraggo.Edmx/ you can install it via NuGet within Visual Studio and it serves up ALL of the metadata from your EDMX files that Microsoft hides from you, very simple, works great. You want access to all that low level storage information like your property SQL types, the schema, it's all there. You can even use the Sample Windows.Forms app in the github repo to set a breakpoint and examine the data.
Facing this issue a few weeks ago. As a result create Xslt transformation of EDMX to XSD. https://wash-inside-out.blogspot.com/2022/12/edmx-file-to-xsd-with-xslt.html