C# - Exception When Generating An Excel Document From A Repeater?

Feb 3, 2011

I have pretty much followed this thread Export to Excel from a Repeater?, however, I get an exception saying

155|error|500|Control 'XXX' of type 'LinkButton' must be placed inside a form tag with runat=server.|

The LinkButton is defined in the HeaderTemplate, so how do I fix this problem?

Updated: The form tag is in the master page with runat="server"

View 1 Replies


Similar Messages:

Forms Data Controls :: Exporting Gridview Into Excel Is Not Generating The Result On Excel File?

Apr 1, 2010

when I used a code of exporting gridview into excel this code worked for a new website which is without masterpage.

my code:

public override void VerifyRenderingInServerForm(Control control) { }
protected void BtnGenerateReport_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition",
"attachment;filename=GridViewExport.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();.....

Now the same code when I copy it in my project having masterpage . there is no compiler error but it is genereating excel file withno data in it but in fact there is data in the grid view at runtime.

View 2 Replies

Generating A Pdf Text Document?

Jul 7, 2010

I am trying to generate a pdf document using the following code which i picked up from one of these forums. It had worked fine when I exported a gridview to pdf.

Now I need to export HTML code to pdf. Can someone suggest how to proceed, possibly using the gridview exporting code below? Any other approach is also welcome.

Code:

Response.ContentType = "application/pdf";
filename = "DocumentName.pdf";
Response.AddHeader("content-disposition", "attachment;filename=" + filename);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gridView1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.B2, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
string sFinanceReportpath = ConfigurationManager.AppSettings["UploadFinanceReportPath"].ToString();
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, new FileStream(sFinanceReportpath + filename, FileMode.Create));
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
//Response.Write(pdfDoc);
//Response.End();

View 4 Replies

Php - Generating An Excel File On The Fly In A Website?

Jan 14, 2011

Are there any good PHP libraries for exporting data to Excel files (not CSV files)?

(An alternative would be creating an ASP.NET Web service that handles Excel file generation, but I would rather not send complex objects over a network in XML format, unless it were strictly necessary.)

View 3 Replies

Web Forms :: Generating Graph In Excel?

Feb 3, 2010

I have a web application which will write a set of values returned from

View 4 Replies

Generating Excel File For Email Attachment?

Jan 6, 2011

I currently have a page which displays a report of multiple tables with the data values in them based on two parameters selected in dropdowns.

Now, I need to generate the same report for each combination of the two parameters as a worksheet in an Excel workbook to be sent as an email attachment. This is to be automatically generated daily, and I'm using the Global.asax to do this task at 1 day intervals. So each sheet will display multiple tables, one below the next, just like they display on the web page where the user can go to view them on demand.

I've seen plenty of resources for exporting a gridview to Excel, where a user clicks and is prompted to download an Excel file, but this is different.

View 3 Replies

Web Forms :: Generating An Excel File From A DataTable?

May 25, 2010

In my site I have no App_Code folder, no Bin folder, no codebehind files, and no web.config. I need to make a form that exports an Excel spreadhseet filled with database results. Anything I do has to run out of the inline script runat="server" block at the top of the page.

View 2 Replies

Web Forms :: Null Reference Exception In Document.getElementById?

Dec 10, 2010

I am getting the Null reference exception in

[Code]....

also when I used the Quickwatch, I get this error message.

getElementById The name 'getElementById' does not exist in the current context

I am also using Master Pages.

View 5 Replies

Generating Multiple Excel Sheet Using Reporting Services 2005?

Aug 31, 2010

I'm currently developing a program using ASP.NET 2.0 (C#) and i am using Reporting Services 2005. One of the report requirements is to export a data to an excel with multiple excel sheet.

Is there other way to generate multiple excel sheet using the reporting services? if yes, i would like to ask a sample code..

View 6 Replies

Web Forms :: Exporting To Excel: Generating Microsoft JScript Runtime Error

Mar 14, 2011

I am trying to write a bit of code that will export the current contents of a gridview to an excel file on the local system. I've looked at several examples on how to do it and implemented it. However, i am unable to get the gridview to export the data.

Here's the basics of what i am doing:

I'm using httpcontext.current.response to specify the file contents and filename. creating Stringwriter and htmltextwriter objects.

then rendering the table into the htmlwriter then rendering the htmlwriter to the response.

however, regardless of how large or small the table i am working with is, i keep getting the following error:

[Code]....

Visual Studio opens a file called ScriptResource.axd and the error is noted in the following section of code at the throw error line.

[Code]....

I have included the Public Overrides Sub VerifyRenderingInServerForm(ByVal ctl As Control) method as suggested by others but this has not resolved my issue. I am not sure how to proceed.

View 3 Replies

Read Data From Excel Document?

Sep 28, 2010

I want to read Excel document using C#. I am not a professional so I need examples to learn the technique. If anyone provides useful link, information, api library.

View 2 Replies

Controls :: Convert PDF Document To Excel File Using C#

Aug 7, 2013

How to convert pdf to excel.

Like on my webpage i upload pdf file and it gives me excel file to download.

View 1 Replies

Web Forms :: Inject Doc / Excel Document Content To Webpage

Jan 11, 2010

We have some table with messages. Each message could have attachments.

We need to have text of attachmnet inside html table of messages on web page. For the first stage we need to have at least support of doc, excel attachments (in future possibly will desire pdf). So in table we show from, subject and body as html cells of message tr. And cell for body should contain firstly rendered content of attached documents (with all images and styles), and then real message body. They don't want any links for download or something similar :(

I know only about possibility to use MS Word Save As logic (but don't have a lot of details). So in this case I should have MS word, excel installed on server. And based on type of attachment use one of the compopnents.

View 4 Replies

Sharepoint - Display An Excel 2010 Document In A Web Application?

Jul 12, 2010

I am wanting to display an excel 2010 document in an asp.net web application. This document uses the new slicer functionality which I want to be available to the user.I know that excel 2010 docs can be used within sharepoint by inserting a web part which uses exceservices.But can it be achieved without sharepoint? Or can it be achieved using the the excelservices API to get the document from shreapoint and then somehow get it to the browser in .net?

View 1 Replies

Web Forms :: Convert Document (Word / Excel / PDF) To Image (JPG)

Apr 27, 2016

How to convert Document (word, Excel, PDF) convert to jpg ....

View 1 Replies

Web Forms :: Reading Data From An Excel Document Posted Via FileUpload Control?

Jun 9, 2010

I am working on a comparison tool that will take an excel file and a .csv file and find differences. The user is going to be selecting the two files from their local machine via the .NET FileUpload control. The issue I am running into is that I don't want to write the files to the server first so using something like below won't work for me, as "Book1.xls" or even " + FilePath + " in place of it won't work. I need to be able to read the posted files into memory, then create maybe datatables of them, then do my comparison code.

[Code]....

I have some code that reads the PostedFile into a stream but I don't know how I can use that stream with the above code. Then I have some that can read the .csv file, but if it is an excel file, I get a bunch of Excel garbage along with the data...

[Code]....

How can I read into clean data from a FileUpload control of an Excel document?

View 5 Replies

DataSource Controls :: Datatable To Excel Memory Exception?

Feb 1, 2010

[Code]....

View 4 Replies

Controls :: Export To Excel - System Is Out Of Memory Exception

Nov 22, 2013

We are using below code to export gridview data to excel. It is working fine when export 2 or 3 months data with more than 120,000 rows but we can try to export data for more than 12 months which almost contain 480,000 rows so it generates error

"System is out of memory exception" ....

View 1 Replies

Possible To Export Repeater To Excel

Jan 12, 2010

I am trying to export my repeater to excel and here is my code...

StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
string attachment = "attachment; filename=file.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
[code]...

View 2 Replies

Import Excel File To Sql Using Bulkcopy / Exception Message: 'C:MyTest.xls' Is Not A Valid Path

Mar 2, 2011

I have been able to import an excel file sql bulkcopy locally. But when I publish the code to the server I get the following error messages:

Exception Message: 'C:MyTest.xls' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

Exception Source: Microsoft JET Database Engine

Here is code:

[code]....

View 2 Replies

Web Forms :: Export Repeater Data To Excel?

Apr 17, 2012

i want to create a asp.net page which consists of repeater control and want to export repeater data in excel.

View 1 Replies

Forms Data Controls :: Export Repeater To Excel?

Sep 20, 2010

protected void RunReport(object sender, EventArgs e)

View 4 Replies

Data Controls :: Export Repeater Control With TemplateField To Excel?

Jul 17, 2015

I have a repeater control which has an table format that has textboxes in it. I tried the solution at [URL] which works but loses the table format. I have an example below in which I have modified that code and have it so now the table format stays but the values show outside the table and not in the correct columns and rows.

I need to keep the values in the proper location.

<asp:Repeater ID="rptMonthlyReport" runat="server" OnItemDataBound="rptMonthlyReport_ItemDataBound">
<HeaderTemplate>
<header>
<asp:Label ID="lblOne" runat="server">Monthly Performance Report</asp:Label>
</header>
<table id="tblMonthlyReport" border="1">

[code].....

View 1 Replies

Data Controls :: Export Repeater Control With TextBox In ItemTemplate To Excel

Jul 17, 2015

I have a repeater control that is getting exported to excel. Well excel will no longer show the data that was in the textboxes. I've read the article on exporting a gridview having the same problem and how you replace the texboxes with literal contrls. I was wondering if there is an article like it only for a repeater control.

View 1 Replies

Web Forms :: Ajax Collapsible Panel Inside Repeater Control - Export To Excel

Jun 25, 2010

I am getting this error Extender control 'cpeProject' is not a registered extender control. Extender controls must be registered using RegisterExtenderControl() before calling RegisterScriptDescriptors(). Parameter name: extenderControl This is the itemtemplete code for repeater in aspx page.

<
ItemTemplate
>
<tr
>
<td
align="left"
style
="width: 15%; font-size: 11px; font-family: Verdana;">
<%
#DataBinder.Eval(Container.DataItem,
"Employee_RollNo"
)%>
</td
>
<td
>
<asp:Panel
ID="pnlProject"
runat
="server">
<asp:LinkButton
ID="LinkButton1"
runat="server"
CommandArgument='<%#Bind("Employee_RollNo") %>'><%#DataBinder.Eval(Container.DataItem,"Full_Name")
%></asp:LinkButton
>
</asp:Panel
>
<asp:Panel
ID="Panel1"
runat
="server">
<cc1:CollapsiblePanelExtender
ID="cpeProject"
ExpandedSize="0"
CollapsedSize
="0"
TargetControlID="pnlSurvery"
ExpandControlID="LinkButton1"
CollapseControlID
="LinkButton1"
SuppressPostBack="true"
runat="server"
Collapsed
="false">
</cc1:CollapsiblePanelExtender
>
</asp:Panel
>
</td
>
<td
align="left"
style
="width: 15%; font-size: 11px; font-family: Verdana;">
<%
#DataBinder.Eval(Container.DataItem,
"Sec_name"
)%>
</td
>
<td
align="left"
style
="width: 15%; font-size: 11px; font-family: Verdana;">
<%
#DataBinder.Eval(Container.DataItem,
"Div_Name"
)%>
</td
>
<td
align="left"
style
="width: 15%; font-size: 11px; font-family: Verdana;">
<%
#DataBinder.Eval(Container.DataItem,
"Grade_Name"
)%>
</td
>
<td
align="left"
style
="width: 15%; font-size: 11px; font-family: Verdana;">
<%
#DataBinder.Eval(Container.DataItem,
"Location"
)%>
</td
>
</tr
>
<tr
class
="ItemTemplate">
<td
colspan="8"
style
="width: 100%">
<asp:Panel
ID="pnlSurvery"
runat="server"
Width="100%"
Height
="100%">
<table
cellpadding
="10">
<tr
>
<td
>
<table
border="0"
cellpadding="0"
cellspacing
="0">
<tr
>
<td
>
<asp:Panel
ID="pnlBehaviour"
runat="server"
Visible
="false">
<table
border
="0">
<tr
>
<td
align="left"
style
="background-color: Navy">
<asp:Label
ID="Label1"
runat="server"
Font-Size="14px"
Font-Bold="True"
ForeColor="white">Functional/Behaviour Report</asp:Label
>
</td
>
</tr
>
<tr
>
<td
>
<asp:GridView
ID="gvBehaviour"
runat="server"
AllowPaging="true"
AutoGenerateColumns
="False"
Font-Size
="medium">
<AlternatingRowStyle
Font-Bold="False"
Font-Italic="False"
Font-Overline
="False"
Font-Strikeout="False"
Font-Underline="False"
BackColor="Lavender"
/>
<Columns
>
<asp:BoundField
DataField="TRAINING_PROGRAMS"
HeaderText="TRAINING_PROGRAMS"
/>
<asp:BoundField
DataField="REMARKS"
HeaderText="REMARKS"
/>
<asp:BoundField
DataField="TIME_PERIOD"
HeaderText="TIME_PERIOD"
/>
<asp:BoundField
DataField="RESPONSIBLE"
HeaderText="RESPONSIBLE"
/>
</Columns
>
<HeaderStyle
Wrap="true"
BackColor="Navy"
Font-Bold="False"
Font-Italic="False"
Font-Overline
="False"
Font-Strikeout="False"
Font-Underline="False"
ForeColor="White"
/>
</asp:GridView
>
</td
>
</tr
>
</table
>
</asp:Panel
>
</td
>
</tr
>
<tr
>
<td
>
<br
/>
<br
/>
<asp:Panel
ID="pnlOther"
runat="server"
Visible
="false">
<table
border
="0">
<tr
>
<td
align="left"
style
="background-color: Navy">
<asp:Label
ID="lblHeading1"
runat="server"
Font-Size="14px"
Font-Bold="True"
ForeColor="white">Other Training Requirements, if any</asp:Label
>
</td
>
</tr
>
<tr
>
<td
>
<asp:GridView
ID="gvOther"
runat="server"
AutoGenerateColumns="False"
Font-Size
="medium">
<AlternatingRowStyle
Font-Bold="False"
Font-Italic="False"
Font-Overline
="False"
Font-Strikeout="False"
Font-Underline="False"
BackColor="Lavender"
/>
<Columns
>
<asp:BoundField
DataField="BT_DESCRIPTION"
HeaderText="TRAINING_PROGRAMS"
/>
<asp:BoundField
DataField="BT_REMARKS"
HeaderText="REMARKS"
/>
<asp:BoundField
DataField="BT_DURATION"
HeaderText="TIME_PERIOD"
/>
<asp:BoundField
DataField="BT_COST"
HeaderText="RESPONSIBLE"
/>
</Columns
>
<HeaderStyle
Wrap="true"
BackColor="Navy"
Font-Bold="False"
Font-Italic="False"
Font-Overline
="False"
Font-Strikeout="False"
Font-Underline="False"
ForeColor="White"
/>
</asp:GridView
>
</td
>
</tr
>
</table
>
</asp:Panel
>
</td
>
</tr
>
<tr
>
<td
>
<asp:Panel
ID="pnlTechnical"
runat="server"
Visible
="false">
<br
/>
<table
>
<tr
>
<td
align="left"
style
="background-color: Navy">
<asp:Label
ID="lblHeading"
runat="server"
Font-Size="14px"
Font-Bold="True"
ForeColor
="white"
Width="503px">Technical Report</asp:Label
>
</td
>
</tr
>
<tr
>
<td
>
<asp:GridView
ID="gvTechnical"
runat="server"
AutoGenerateColumns="False"
Font-Size
="medium">
<AlternatingRowStyle
Font-Bold="False"
Font-Italic="False"
Font-Overline="False"
/>
<Columns
>
<asp:BoundField
DataField="TRAINING_PROGRAMS"
HeaderText="TRAINING_PROGRAMS"
/>
<asp:BoundField
DataField="REMARKS"
HeaderText="REMARKS"
/>
<asp:BoundField
DataField="TIME_PERIOD"
HeaderText="TIME_PERIOD"
/>
<asp:BoundField
DataField="RESPONSIBLE"
HeaderText="RESPONSIBLE"
/>
</Columns
>
<HeaderStyle
Wrap="true"
BackColor="Navy"
Font-Bold="False"
Font-Italic="False"
Font-Overline
="False"
Font-Strikeout="False"
Font-Underline="False"
ForeColor="White"
/>
</asp:GridView
>
</td
>
</tr
>
</table
>
</asp:Panel
>
</td
>
</tr
>
<tr
>
<td
>
<asp:Panel
ID="pnlAssignment"
runat="server"
Visible
="false">
<br
/>
<table
>
<tr
>
<td
align="left"
style
="background-color: Navy">
<asp:Label
ID="Label2"
runat="server"
Font-Size="14px"
Font-Bold="True"
ForeColor
="white"
Width="503px">Assignments/Projects Report</asp:Label
>
</td
>
</tr
>
<tr
>
<td
>
<asp:GridView
ID="gvAssignment"
runat="server"
AutoGenerateColumns="False"
Font-Size
="medium">
<AlternatingRowStyle
Font-Bold="False"
Font-Italic="False"
Font-Overline="False"
/>
<Columns
>
<asp:BoundField
DataField="TRAINING_PROGRAMS"
HeaderText="TRAINING_PROGRAMS"
/>
<asp:BoundField
DataField="REMARKS"
HeaderText="REMARKS"
/>
<asp:BoundField
DataField="TIME_PERIOD"
HeaderText="TIME_PERIOD"
/>
<asp:BoundField
DataField="RESPONSIBLE"
HeaderText="RESPONSIBLE"
/>
</Columns
>
<HeaderStyle
Wrap="true"
BackColor="Navy"
Font-Bold="False"
Font-Italic="False"
Font-Overline
="False"
Font-Strikeout="False"
Font-Underline="False"
ForeColor="White"
/>
</asp:GridView
>
</td
>
</tr
>
</table
>
</asp:Panel
>
</td
>
</tr
>
</table
>
</td
>
</tr
>
</table
>
</asp:Panel
>
</td
>
</tr
>
</ItemTemplate
>
code behind for Exporting it to excel
protected void btnExport_Click(object sender,
EventArgs e)
{
if (Repeater1.Items.Count > 0)
{
// RegisterCollapsibleExtender();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer =
true;
HttpContext.Current.Response.ContentType =
"application/vnd.ms-excel";
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename = EDReport.xls");
HttpContext.Current.Response.Charset =
"";
StringWriter sw =
new StringWriter();
HtmlTextWriter htw =
new HtmlTextWriter(sw);
//ScriptManager sm = ScriptManager.GetCurrent(Page);
//sm.RegisterExtenderControl(cpeProject, pnlSurvery);
//sm.RegisterAsyncPostBackControl(LinkButton1);
Repeater1.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
}

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved