Y
yyt
I am programmatically adding a web user control to a webform. This User
Control displays the employee listing from a database into a datagrid. But
the calling webform should render the data as a excel spreadsheet.
I had the same logic working when the app had a simple web form with a
datagrid embedded in it. But it gives error when I separate the logic into a
pagelet. Below are the details:
=========
Code:
webform1.aspx
<%@ Page ....%>
<%@ Reference Control ="~/emplist.ascx"%>
<!DOCType....>
<html>
<head>
<link href="../styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<form id="Test" method="post" runat="server"></form>
</body>
</html>
webform1.aspx.vb
private sub Page_Load(Byval sender as System.object, ...)
response.contenttype = "application/ms-excel"
response.AddHeader("Content-Disposition","inline;filename=emplist.xls")
dim sPath as string = "~/modules/emplist.ascx"
dim c1 as Control = LoadControl(sPath)
dim objForm as Control = Page.FindControl('Test") ' pass the name
of the form
objForm.Controls.Add(c1)
end sub
emplist.ascx: has a datagrid and the binds a dataset in the page_load event.
Error:
"Microsoft Excel" error prompt: Unable to read file.
"HTML Import Errors" prompt:
Problems came us in the following areas during load:
Missing fle: ...\Local Settings\Temporary Internet
Files\Content.IE5\styles.css
=========
Is there a better ( and easier ) approach to the above?
Thanks
yyt
Control displays the employee listing from a database into a datagrid. But
the calling webform should render the data as a excel spreadsheet.
I had the same logic working when the app had a simple web form with a
datagrid embedded in it. But it gives error when I separate the logic into a
pagelet. Below are the details:
=========
Code:
webform1.aspx
<%@ Page ....%>
<%@ Reference Control ="~/emplist.ascx"%>
<!DOCType....>
<html>
<head>
<link href="../styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<form id="Test" method="post" runat="server"></form>
</body>
</html>
webform1.aspx.vb
private sub Page_Load(Byval sender as System.object, ...)
response.contenttype = "application/ms-excel"
response.AddHeader("Content-Disposition","inline;filename=emplist.xls")
dim sPath as string = "~/modules/emplist.ascx"
dim c1 as Control = LoadControl(sPath)
dim objForm as Control = Page.FindControl('Test") ' pass the name
of the form
objForm.Controls.Add(c1)
end sub
emplist.ascx: has a datagrid and the binds a dataset in the page_load event.
Error:
"Microsoft Excel" error prompt: Unable to read file.
"HTML Import Errors" prompt:
Problems came us in the following areas during load:
Missing fle: ...\Local Settings\Temporary Internet
Files\Content.IE5\styles.css
=========
Is there a better ( and easier ) approach to the above?
Thanks
yyt