|
|
Thanks for your answer, I will check it.
I Love SQL
|
|
|
|
|
hi this is my procedure to export my .rpt to pdf, xls, doc or rtf. it's working good but when it comes to last line crReportDocument.Export(); ...plz once go through this code and kindly please help me out ......
In page load
-----------------------------
protected void btnGenRep_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection("_constr");
con.Open();
SqlCommand cmd = new SqlCommand("GetLocations", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = cmd;
da.Fill(ds, "tbLocations");
cmd.ExecuteNonQuery();
con.Close();
ReportDocument myReportDocument;
myReportDocument = new ReportDocument();
myReportDocument.Load(Server.MapPath("CrystalReport.rpt"));
myReportDocument.SetDataSource(ds);
CrystalReportViewer1.ReportSource = myReportDocument;
string rptFormat = ddlformat.SelectedItem.Value.ToString();
string format = GetReportFormat(rptFormat);
string repname = "CrystalReport." + format;
pal pall = new pal();
string ExportFile=pall.LoadReport(Request.PhysicalApplicationPath, rptFormat, myReportDocument, repname);
Response.Write("window.open(Exported/'" + ExportFile + "');");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally { }
}
public string GetReportFormat(string type)
{
switch (type)
{
case "DOC":
return "DOC";
case "XLS":
return "XLS";
case "RTF":
return "RTF";
case "PDF":
default:
return "PDF";
}
}
In class file
public string LoadReport(string path, string exportfile, ReportDocument crReportDocument, string filename)
{
ExportOptions crExportOptions ;
DiskFileDestinationOptions crDiskFileDestinationOptions;
string ExportPath;
ExportPath = path + "Exported\\";
if (Directory.Exists(ExportPath) == false)
{
Directory.CreateDirectory(path + "Exported\\");
}
crDiskFileDestinationOptions = new DiskFileDestinationOptions();
crExportOptions = new ExportOptions();
crExportOptions = crReportDocument.ExportOptions;
if (exportfile == "RTF")
{
crDiskFileDestinationOptions.DiskFileName = ExportPath + filename;
crExportOptions.ExportDestinationType=ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType=ExportFormatType.RichText;
}
if (exportfile == "PDF")
{
crDiskFileDestinationOptions.DiskFileName = ExportPath + filename;
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
}
if (exportfile == "XLS")
{
crDiskFileDestinationOptions.DiskFileName = ExportPath + filename;
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType = ExportFormatType.Excel;
}
if (exportfile == "DOC")
{
crDiskFileDestinationOptions.DiskFileName = ExportPath + filename;
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType = ExportFormatType.WordForWindows;
}
try
{
crReportDocument.Export();->>> Error is occurred here
return filename;
}
catch (Exception ex)
{
throw (ex);
}
finally { }
}
|
|
|
|
|
What is the exception you get?
|
|
|
|
|
here im getting exception as
Object reference is not set to an instance
thanks...
|
|
|
|
|
Did you attach your debugger to see where it derails accessing a NULL?
|
|
|
|
|
while in debug mode its giving
filename as rassdk://D:\Crystal_US\CrystalReport.rpt
filepath= D:\Crystal_US\CrystalReport.rpt
is thr anything wrong with this and its giving no where its assisgned to NULL
|
|
|
|
|
deepak sir ....
if u don mind i will end my sample project .. cud u plz go thru it .... plzz
|
|
|
|
|
Hi friends,
I working in a module which would look like Windows Explorer, a Folder tree on the left and a File and folder list on the right.
Loading the folder is working fine and loading the right pane to the selected tree node is also done. The right pane data are loaded dynamically. Each files and folders are Linkbutton generated on runtime. I am not able to retain that controls when any of the link button is clicked. I have added a Click event for the Linkbutton which would open that folder and loads the inner data. When the page postbacks, this linkbuttons are cleared and the Click event is not called since the Page lost that control.
Anybody have an idea to solve this problem?
Thanks in advance...
|
|
|
|
|
|
No Vasu. I have tried it.
The sad part is when the Page is postbacked all the Link Buttons created dynamically are cleared.
|
|
|
|
|
I am calling a method getDirectories() present in an Applet which returns a string value, am calling this from the javascript. When I run this script from the Internet Explorer, the getDirectories() returns “C:, D:” but when I am calling this method from the Firefox it returns [Object Event] but I am expecting “C:, D:”. Can you please help me what should I do to get the correct string value.
Thanks in Advance
Irsh
|
|
|
|
|
|
|
|
hi guys,
How to invoke Asynchronous web service from asp.net web application. through delegate we can achieve the Asynchronous call.
can u give some example or any URL?
Thanks & Regards
velu
|
|
|
|
|
|
Thanks Deepak. i ll gothrough and come back.
d.sengottuvelu
|
|
|
|
|
i have an image control in item template of a datalist and file upload control in edit item template. if i upload a picture, for first time, the image control show the new image. but from onwards if i upload a new picture, even though its uploaded to server and the path is shown with new image name, it shows the old picture untill i refresh the page. what would be the solution for this problem. If i disable cache will it work, if yes how to disable cache. The whole thing is in an .ascx (user control) page.
minah
|
|
|
|
|
fthavha wrote: Disable cache
There is nothing like disabling cache. With so many cache tiers at IIS, Proxy, Upstream servers and Web browser level, you can not expect a perfect disabling of cache though. You can of course direct the element to expire from cache or not to be cached by a suitable (pragma) or other directive.
|
|
|
|
|
so please tell me what should i do to show the new images
|
|
|
|
|
|
|
I have a page which adds a record to the database when I Click the submit button and it stays in the same page showing all values from the database in a datalist. My problem is that if I refresh the page, the last event fired , that is btnSubmit_Click is fired again and yet another a record is added to database. What will be the solution. Thanks in advance
minah
|
|
|
|
|