PL wrote:
Any other ideas? I'm guessing from your response that there's no reason for this not to work under asp.net 2.0?
Make sure all tags are properly closed, validate the html.
Strange results can happen if there are unclosed tags within the form ruant=server
and inside the datagrid/gridview.
Bizarrely I had a 'runat=server' in the <head> tags :) however removing
that did not solve the problem, and I couldn't find any other issues.
I apologise for the code-dump but if it helps this is the page causing
issues...(bigsearchresults.aspx)
**********************************************
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="BigSearchResults.aspx.vb" Inherits="BigSearchResults" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Results!</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btExport" runat="server" OnClick="btExport_Click"
Text="Export" Style="position: relative; z-index: 100;" />
<asp:SqlDataSource ID="dsSearch" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
SelectCommand="aspBigSearch" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter SessionField="ac" Name="ac" Type="String" />
<asp:SessionParameter SessionField="ad" Name="ad" Type="String" />
<asp:SessionParameter SessionField="cd" Name="cd" Type="String" />
<asp:SessionParameter SessionField="course" Name="course"
Type="String" ConvertEmptyStringToNull="false" />
<asp:SessionParameter SessionField="yearfrom" Name="gradyearfrom"
Type="Int32" DefaultValue="0" />
<asp:SessionParameter SessionField="yearto" Name="gradyearto"
Type="Int32" DefaultValue="0" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="gvSearch" runat="server" DataSourceID="dsSearch"
BackColor="Silver" EmptyDataText="Sorry, your search has come up empty!"
AllowSorting="false">
</asp:GridView>
</div>
</form>
</body>
</html>
*******************************************
the codebehind bigsearchresults.vb is thus:
*******************************************
Partial Class BigSearchResults Inherits System.Web.UI.Page
Protected Sub btExport_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btExport.Click
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
gvSearch.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
End Sub
****************************
Really apprecaite any help!
Cheers,
Chris