|
I can answer you regardin the render method ... you probably meant the ReportViewer.LocalReport.Render method ... well its the main method in the ReportViewer Control ... this method uses the report definition (which is an xml format stored in rdlc file referring to the report) to render the report defintion with its data to the ASP.NET page ... the LocalReport will have the definition and its integrated with the stored procedure or the datasource ... then using some parameters to the render method you get an array of bytes which is the output you want ...
Take a look at the code below:
string format="PDF";
Warning[] warnings;
string[] streamIDs;
string mimeType;
string encoding;
string extension;
string deviceInfo = "<deviceinfo><simplepageheaders></simplepageheaders></deviceinfo>";
byte[] buffer = viewer.LocalReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamIDs, out warnings);
this.Response.Clear();
this.Response.AddHeader("Content-Type", mimeType);
this.Response.AddHeader("Content-Disposition", "attachment; filename=" + reportName + "." + extension);
this.Response.BinaryWrite(buffer);
this.Response.End();
The above code will render the specified local report as PDF and return the result as an array of bytes ... then you write this array of bytes to back to the response as a dialog of Open or Save ...
I needed this trick in a project and it worked fine with me ... I could render the report to PDF Excel or whatever I can to be as the user can just download easly.
Hope this could help ...
Sincerely Samer Abu Rabie
Note: Please remember to rate this post to help others whom reading it.
|
|
|
|
|
I will definitely give it a shot. Thank you!
Revolutionary: Disk drives go round and round.
|
|
|
|
|
Ok, here is what I really what to do. How to I hide the DistributorID when loaded but display it when the excel file is exported.
You might be thinking why don't I delete it form the page_load then, well I can't do that cause then my cells will not match up to the database
to the LinkButton1_Click event
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class manager_view_distributors : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AlternaDB.MarketingDataContext db = new AlternaDB.MarketingDataContext();
var products = from p in db.Distributors
select new { p.DistributorID, Company_Name = p.CompanyName, Address = p.AddressLine1, p.City, Zip_Code = p.ZipCode, p.State, First_Name = p.Contact1FirstName, Last_Name = p.Contact1LastName, Area_Code = p.Contact1WorkAreaCode, Phone = p.Contact1WorkNumber, Num_Stores = p.NumStores, Num_DSC = p.NumDsc };
GridView1.DataSource = products;
GridView1.DataBind();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
GridView1.PageSize = Int32.Parse(DropDownList1.SelectedValue); this.GetData();
}
private void GetData()
{
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.GetData();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (this.rdoBtnListExportOptions.SelectedIndex == 1)
{
// the user wants all rows exported, turn off paging
// and rebing the grid before sending it to the export
// utility
ExportExcelColumns();
this.GridView1.PageSize = 1000000;
GridView1.DataBind();
}
else if (this.rdoBtnListExportOptions.SelectedIndex == 2)
{
// the user wants just the first 100,
// adjust the PageSize and rebind
ExportExcelColumns();
this.GridView1.PageSize = 100;
GridView1.DataBind();
}
//Current Page export
else if (this.rdoBtnListExportOptions.SelectedIndex == 0)
{
ExportExcelColumns();
GridView1.DataBind();
}
GridViewExportUtil.Export("Customers.xls", this.GridView1);
}
private void ExportExcelColumns()
{
// pass the grid that for exporting ...
AlternaDB.MarketingDataContext db = new AlternaDB.MarketingDataContext();
var dist = from d in db.Distributors
select new
{
d.DistributorID,
AccountType = SalonForm.DistAccountType.GetDistAccountTypeByValue((int)d.AccountType),
AccountStatus = SalonForm.AccountStatus.GetAccountStatusByValue((int)d.AccountStatus),
d.CompanyName,
d.AddressLine1,
d.AddressLine2,
d.City,
d.State,
d.Country,
d.ZipCode,
d.Territory,
d.NumDsc,
d.NumStores,
d.Website,
Contact1Type = SalonForm.DistCustomerType.GetDistCustomerTypeByValue((int?)d.Contact1Type),
d.Contact1FirstName,
d.Contact1LastName,
d.Contact1Email,
d.Contact1WorkIntlPrefix,
d.Contact1WorkAreaCode,
d.Contact1WorkNumber,
d.Contact1WorkExtension,
d.Contact1CellIntlPrefix,
d.Contact1CellAreaCode,
d.Contact1CellNumber,
d.Contact1CellExtension,
d.Contact1ReceiveEnews,
Contact2Type = SalonForm.DistCustomerType.GetDistCustomerTypeByValue((int?)d.Contact2Type),
d.Contact2FirstName,
d.Contact2LastName,
d.Contact2Email,
d.Contact2WorkIntlPrefix,
d.Contact2WorkAreaCode,
d.Contact2WorkNumber,
d.Contact2WorkExtension,
d.Contact2CellIntlPrefix,
d.Contact2CellAreaCode,
d.Contact2CellNumber,
d.Contact2CellExtension,
d.Contact2ReceiveEnews,
Contact3Type = SalonForm.DistCustomerType.GetDistCustomerTypeByValue((int?)d.Contact3Type),
d.Contact3FirstName,
d.Contact3LastName,
d.Contact3Email,
d.Contact3WorkIntlPrefix,
d.Contact3WorkAreaCode,
d.Contact3WorkNumber,
d.Contact3WorkExtension,
d.Contact3CellIntlPrefix,
d.Contact3CellAreaCode,
d.Contact3CellNumber,
d.Contact3CellExtension,
d.Contact3ReceiveEnews,
Contact4Type = SalonForm.DistCustomerType.GetDistCustomerTypeByValue((int?)d.Contact4Type),
d.Contact4Firstname,
d.Contact4LastName,
d.Contact4Email,
d.Contact4WorkIntlPrefix,
d.Contact4WorkIntlAreaCode,
d.Contact4WorkNumber,
d.Contact4WorkExtension,
d.Contact4CellIntlPrefix,
d.Contact4CellAreaCode,
d.Contact4CellNumber,
d.Contact4CellExtension,
d.Contact4ReceiveEnews,
Contact5Type = SalonForm.DistCustomerType.GetDistCustomerTypeByValue((int?)d.Contact5Type),
d.Contact5FirstName,
d.Contact5LastName,
d.Contact5Email,
d.Contact5WorkIntlPrefix,
d.Contact5WorkAreaCode,
d.Contact5WorkNumber,
d.Contact5WorkExtension,
d.Contact5CellIntlPrefix,
d.Contact5CellAreaCode,
d.Contact5CellNumber,
d.Contact5CellExtenstion,
d.Contact5ReceiveEnews,
d.DateCreated,
d.Username,
d.Password
};
GridView1.DataSource = dist;
}
protected void BrowseDistGrid_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void rdoBtnListExportOptions_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void LinkButton1_Click1(object sender, EventArgs e)
{
GridViewRow gvr = (GridViewRow)((LinkButton)sender).Parent.Parent; //get that selected row
//string AccountType = gvr.Cells[16].Text;
string CompanyName = gvr.Cells[2].Text;
string Address1 = gvr.Cells[3].Text;
Response.Redirect("Distributor.aspx?CompanyName=" + CompanyName
+ "&Address1=" + Address1
); //redirect to next page with selected values
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header | e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Controls[1].Visible = false;
}
}
}
|
|
|
|
|
Hi there...
I have couple of comments on your question:
First of all ... Haven't you notice that you have posted a newspaper here !!! This is not a good thing ... how many members do you think will read or read your post?! None !! because no one will have the time to read all this to figure out the problem you are posting and find a solution for you !!
Second of all ... When posting code in your question put it in code tags .. its easier for the readers to distinguish the question body from the code in the post.
We could help if you post a problem ... not a project to be rewritten all over again or something like that ... try to rewrite your problem so others could try to help you out.
Sincerely Samer Abu Rabie
Note: Please remember to rate this post to help others whom reading it.
|
|
|
|
|
Screw off no one what's to hear your compliants, get a life.
|
|
|
|
|
We're using ASP.NET 2.0 FormView control wrapped by a web user control to handle CRUD UI operations. It works well except for confirmation PRIOR to insert or update. All the links I find on "confirmation" are the response.redirect type after the insert has been made to database. I need to display the data to user one last time prior to insert.
Formview does not appear to have a mechanism for displaying a readonly template of insert/update data PRIOR to insert/update.
Tried Me.fvAccountCC.ChangeMode(FormViewMode.ReadOnly) but user input from viewstate doesn't appear in this mode
Any ideas before I start messy marshalling of user input to duplicate controls in <EmptyDataTemplate> using .FindControl across two instances of usercontrol/formview
ie.
Public Sub SetConfirmTemplate(ByVal Src As ctlAccountCC)
Me.fvAccountCC.DataSourceID = Nothing
CType(Me.fvAccountCC.FindControl("lblAccountName"), Label).Text = CType(Src.FormView.FindControl("txtAccountNo"), TextBox).Text
CType(Me.fvAccountCC.FindControl("lblAccountNo"), Label).Text = CType(Src.FormView.FindControl("txtAccountNo"), TextBox).Text
CType(Me.fvAccountCC.FindControl("imgCardType"), Image).ImageUrl = CType(Src.FormView.FindControl("imgCardType"), Image).ImageUrl
etc...
Thanks.
|
|
|
|
|
Can anybody help me in watermarking the images in DB With a specific text while storing or retrieving for display...
Thanks in Advance
|
|
|
|
|
This really has nothing to do with ASP.NET. It's pretty easy to do tho, surely there are articles on doing that on this site ? All you do is write something on top of the bitmap, typically I'd add that to the code that retrieves the bitmap in your data layer.
You create a graphics object from the bitmap and then you use the methods of that object to draw/write on it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005.
at napajax.Frm_Jobfinder2.getValue() in
|
|
|
|
|
This could be to do with the permission on the ASP.NET user, otherwise, it probably is not related to ASP.NET at all.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
System.UnauthorizedAccessException: Access to the path 'C:\HostingSpaces\consultelvin\napsterjobs.com\wwwroot\resume\muskan22.doc' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at System.Web.HttpPostedFile.SaveAs(String filename)
at System.Web.UI.WebControls.FileUpload.SaveAs(String filename)
at napajax.Frm_Jobfinder2.ImageFileUplodad(String file, String rename)
|
|
|
|
|
ASP.NET does not allow you to access the file system beyond the root of your web app, this could be the root of your other issue, too.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
i m using coustom control and user conrol in page asp.net page .this control added into ajax update panel control . i want to set runtime focus in custom control or user control in control. how to set focus? plz reply
lav naphade
|
|
|
|
|
You need to use javascript to set the focus to a control. To do this, you'll need the client side Id of the control, which is the ClientID property of the server control. Do you know any javascript ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
i know the javascript but i m already using javascript but it is not working properly
For eg:
fucntion focus(customtxt)
{
customtxt.Focus();
}
plz send me solution
lav naphade
|
|
|
|
|
Hi All,
I am getting "Object reference not set to an instance of an object" although I am using "If Not IsPostBack Then .. END IF" while populating the data in the list-box.
Weird thing is that I have been using other Liston having same properties and functionality and they are working fine.
Have u been through this problem before? Any Suggestions?
Thank you very much in advance.
|
|
|
|
|
enthusiastic477 wrote: "Object reference not set to an instance of an object"
This usually comes when u try to access a null object or object that does not exist,please have a look on all the objects u are using to populate the ListBox eg: DataTable,DataSet etc
|
|
|
|
|
It means that your code is broken. Perhaps if you posted it, we could help more.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I was about to publish my site live until I discovered that a DDL is not displaying the first record from the results set! My code is as follows:
if (objRdr.Read())
{
ddlModelTypes.DataSource = objRdr;
ddlModelTypes.DataValueField = "TypeId";
ddlModelTypes.DataTextField = "ModelType";
ddlModelTypes.DataBind();
}
I thought the following line was replacing the first value:
ddlModelTypes.Items.Insert(0, "Other");
However, I took this out and it's still not displaying the first record value so any help will be much appreciated.
Thanks
Lorna
|
|
|
|
|
You do not need to call objRdr.Read(). Try the following.
connection.open
ddlModelTypes.DataSource = objRdr;
ddlModelTypes.DataValueField = "TypeId";
ddlModelTypes.DataTextField = "ModelType";
ddlModelTypes.DataBind();
connection.dispose();
I didn't get any requirements for the signature
|
|
|
|
|
Thanks but I'm using the if (objRdr.Read()) to check that records have been returned as sometimes there will be no records - is there another way to check this before using DataBind?
|
|
|
|
|
It doesn't matter if there's no records, the binding won't fail. You can always check post binding (i.e. count the items in the list) if you need to do something in that case. Calling dr.Read moves the reader onto the second record...
|
|
|
|
|
Do Like this
Member 3402886 wrote: ddlModelTypes.DataSource = objRdr;
ddlModelTypes.DataValueField = "TypeId";
ddlModelTypes.DataTextField = "ModelType";
ddlModelTypes.DataBind();
No need to Call
Member 3402886 wrote: if (objRdr.Read())
No need to Call , otherwise everything else looks ok , it should work
|
|
|
|
|
Hello friends,
I am using a FileUpload Control inside Customized CreateUserwizard Control. I am accessing textboxes inside the CreateUserWizard as ((TextBox)BusinessDetWizardStep.FindControl("txtfirmsname")).Text.Trim().
I also put a fileupload inside this wizard. But while catching the file in code using this code
if(((FileUpload)BusinessDetWizardStep.FindControl("fileupload1")).HasFile)
{
}
The Fileupload control does not get any file to upload...Why this is happening? What could be the cause and solution for this?
Thanks...
|
|
|
|
|
Are you using the fileupload within an updatepanel by any chance?
|
|
|
|
|