I used to work with winForm. Now I need to make a report using Web.
I Need to know how to pass parameters using WebForms. I have something but don't know how to pass it to the other page as parameter to the reportviewer
ReportParameter[] param = new ReportParameter[2];
param[0] = new ReportParameter("usr",Drop_Responsaveis.SelectedValue.ToString());
param[1] = new ReportParameter("clube", Drop_Clientes.SelectedValue.ToString());
Is this right ? Create the parameters at one page and pass it to another page that contains the reportviewer ?
You can use Querystring or Session to pass value to the next page. e.g. page2.aspx?clube=1234&user=John
Then you can retrieve the values from the querystring and pass to the report viewer
param[0] = new ReportParameter("usr", Request.QueryString["user"]);
param[1] = new ReportParameter("clube", Request.QueryString["clube"]);
Related
I have a the following code to fill data for my Asp.net gridview. I used the same code as below in other asp.net page to load data to gridview. All other pages are fine with the code and successfully display gridview with data. But in one page, to display product list of customer purchasing, it display error.
This is my code.
using (DataContext.DBEntities ctx = new DataContext.DBEntities())
{
List<DataContext.vwClientAndProduct> product = new List<DataContext.vwClientAndProduct>();
product = ctx.SP_ClientAndProduct_Select().ToList<DataContext.vwClientAndProduct>();
gvList.DataSource = product.ToList();
gvList.DataBind();
}
I traced the code of the error page, it successfully passed gvList.DataBind() method. But when I continue F5, error message displayed in my product.aspx page. The error starts with 'Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery, DbRawSqlQuery) is not supported....'
Each of the following is not worked too.
var product = (from row in ctx.SP_ClientAndProduct_Select()
select row).ToList();
//var product = from row in ctx.SP_ClientAndProduct_Select()
select row;
//var product = ctx.SP_ClientAndProduct_Select().ToList();
gvList.DataSource = product.ToList();
gvList.DataBind();
The other page is working well with the following.
using (DataContext.DBEntities ctx = new DataContext.DBEntities ())
{
var product = ctx.SP_Product_Select().ToList()
gvList.DataSource = product.ToList();
gvList.DataBind();
}
I don't know why this is not working although the code is same.
Please help.
Thanks
It worked !
I created a new aspx page and copy all code from error page to new page.
When new page load, the gridview displays with data.
Very Strange !
Thanks.
I have successfully Developed a Dynamic web site in Asp.net.
I have Renamed the default URL as Follows.
routes.Add(new DynamicDataRoute("Dashboard.aspx")
{
Action = PageAction.List,
ViewName = "ListDetails",
//Model = DefaultModel,
Table = "SurveyKshan_Survey"
});
The problem is I want to write URL Dynamically according to the value stored in Database
Like if there is a value called NewSurvey I want my url to be like abc.com/NewSurvey and this page should throw me to the login page. Any suggestion on how to proceed.??
I am new ro asp.net any links regarding this would be appreciated.
Thanking you in advance.
I have added reference of my Web Service and I want to show the data generated by Service in Grid View.
Test.getNew fc = new getNew();
fc.getDetail(TextBox1.Text);
The above code gives no result.
If I do
Test.getNew fc = new getNew();
DataSet ds = new DataSet();
ds= fc.getDetail(TextBox1.Text);
Then above code gives an error: Cannot implicitly convert type 'System.Xml.XmlNode' to 'System.Data.DataSet'
Thanks
Your error clearly shows that your web method is returning System.Xml.XmlNode and you are trying to get it in Dataset.
You need to verify two things:
Return type of your webmethod should be the output you expect at client side, in this case dataset.
Your service is able to return dataset.
EDIT
Your solution will look like something:
Test.getNew fc = new getNew();
XmlNode node = fc.getDetail(TextBox1.Text);
DataSet dataset = new DataSet();
if (node!= null)
{
XmlTextReader xmlTextReader = new XmlTextReader(node.OuterXml, XmlNodeType.Element, null);
dataset.ReadXml(xtr);
}
Then use the dataset as datasource for your control.
I am using crystal reports in a .NET 2.0 asp.net website to create a PDF from the report. I then want to stream the report to the browser, which I already know how to do. What I don't know how to do is target the object tag the will hold the PDF. Does someone know how to do this within HTML with javascript or any other way?
Thanks in advance for any help that can be given.
I wanted to come back and answer this after finding out what I had to do. I had to create a separate aspx page and called it PDFView.aspx. I then added the code to the PageLoad event:
if (!IsPostBack)
{
ReportDocument rpt;
rpt = (ReportDocument)Session["CrystalReport"];
System.IO.Stream myStream;
CrystalDecisions.Shared.ExportOptions myExportOptions;
myExportOptions = myReport.ExportOptions;
myExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
myExportOptions.FormatOptions = new CrystalDecisions.Shared.PdfRtfWordFormatOptions();
CrystalDecisions.Shared.ExportRequestContext myExportRequestContext = new CrystalDecisions.Shared.ExportRequestContext();
myExportRequestContext.ExportInfo = myExportOptions;
//SetReportParameter("pPrinterFriendly", true, (ReportClass)myReport);
System.Web.HttpContext.Current.Response.ClearContent();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.ContentType = "application/pdf";
myStream = myReport.FormatEngine.ExportToStream(myExportRequestContext);
Byte[] myBuffer = new Byte[myStream.Length];
myStream.Read(myBuffer, 0, (int)myStream.Length);
System.Web.HttpContext.Current.Response.BinaryWrite(myBuffer);
System.Web.HttpContext.Current.Response.Flush();
}
I created the report object setting all parameters and datasource in the calling aspx page and the wrote the report to a session variable for retrieval when the PDFView.aspx page is loaded. I then used the code above to retrieve, execute and stream the report as a binary stream "the binary PDF" to the browsers response stream.
The PDFView.aspx page is referenced in the calling page with an object tag like this:
<object id="pdfObj" type="application/pdf" style="width:60%;height:95%;position:relative;top:2%;left:0%;right:10%;bottom:10%;margin:0px;padding:0px;border:0px;" data="PDFView.aspx"></object>
I am trying to call rdl reports remotely in ASP.NET, And i was successful calling report without parameter. But when i pass parameter, reporting i not populating and not giving error. It display noting in report. find my code below. and please do suggest me on the same.
MyReportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
MyReportViewer.ServerReport.ReportServerUrl = new Uri(#"http://gblon9sqm10 /ReportServer_DB10");
MyReportViewer.ServerReport.ReportPath = "/Reports/Report1";
MyReportViewer.ShowParameterPrompts = false;
MyReportViewer.ShowPrintButton = true;
ReportParameter[] rptParameters = new ReportParameter[1];
rptParameters[0] = new ReportParameter();
rptParameters[0].Name = "exposureType";
rptParameters[0].Values.Add("Impressions");
MyReportViewer.ServerReport.SetParameters(rptParameters);
MyReportViewer.ServerReport.Refresh();
It's been a while since I set this up but I remember having to make sure that you didn't setup the report again on postback. This is my code in page_load:
if (!Page.IsPostBack)
{
rptViewer.ServerReport.ReportServerUrl = Settings.ReportServerUrl;
if (rptViewer.ServerReport.ReportServerCredentials == null)
rptViewer.ServerReport.ReportServerCredentials = new ReportServerCredentials();
List<ReportParameter> parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter("TitleLabel", "Title string here"));
//More parameters added here...
rptViewer.ServerReport.SetParameters(parameters);
}
I was facing the same problem with same code and configuration as you have mentioned.
I tried bit extra work and get the rid of problem.
I have created a new report with single parameter "Name" and pass value to this parameter from code-behind as ReportParameter. At the report configuration side set the type of parameter text and allow to blank values. Note here i didn't touch any other settings of parameter means kept it as comes by default.
This works for me and then i started adding more parameters and it works perfectly fine.
There is no any browser constraint.
Try as said above and still you face issue then reply me i will put a sample code.
Hope it will help you.