导出到Excel - ASP.net 2.0 [英] Export to Excel - ASP.net 2.0

查看:66
本文介绍了导出到Excel - ASP.net 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在尝试从gridview控件导出到一个excel文件,使用

代码用于数据网格控件(它在网上,如果要求

请发帖。


我收到错误。


控件''gvSearch''类型''GridView''必须放在一个表格标签中

with runat = server。


此错误类似于当数据网格具有

服务器端控件(如编辑按钮等)时经历过,但我的gridview

非常简单,只显示文本字段(它是当然在一个带有runat = server的

表单标签内。


是否有任何调整可以让代码工作?或者是

a完全不同的方法唯一的方法?

干杯,

克里斯

Hi,

I''m trying to export from a gridview control, to an excel file using
code intended for a datagrid control (it''s all over the web, can post if
requested)

I get the error.

Control ''gvSearch'' of type ''GridView'' must be placed inside a form tag
with runat=server.

This error is similar to that experienced when the datagrid had
server-side controls such as edit buttons and the like, but my gridview
is very plain, just displaying text fields (and it is of course inside a
form tag with runat=server).

Are there any tweaks that could be made to allow the code to work? or is
a completely different method the only way?

Cheers,
Chris

推荐答案

查看标签。你的'会看起来像这样:


< / form>

< asp:GridView id =" gvSearch" RUNAT = QUOT;服务器" />


只需确保在< / form>内部移动GridView标记。标签。如果

还有其他元素在标签之外,那么也必须在GridView之上

,也可以将它们拉出来。


这种情况​​通常发生在你在HTML视图中手动编辑标签至少一次之后,在

页面的末尾抛出一些东西时。这很容易修复。


-

Gregory A. Beamer

MVP; MCP:+ I,SE,SD,DBA


**************************** *******************

在盒子外面思考!

********** *************************************

Not Me <无**** @ zxy.blah.org>在消息中写道

news:dl ********** @ ucsnew1.ncl.ac.uk ...
Look at the tags. Your''s will look something like this:

</form>
<asp:GridView id="gvSearch" runat="server" />

Just make sure you move the GridView tag up inside of the </form> tag. If
there are other elements that are outside the tag, that also have to be
above the GridView, pull them up as well.

This normally happens most often when you throw something at the end of a
page after you have hand edited the tags in HTML view at least once. It is
easy to fix.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***********************************************
Think Outside the Box!
***********************************************
"Not Me" <no****@zxy.blah.org> wrote in message
news:dl**********@ucsnew1.ncl.ac.uk...

<我正在尝试使用用于数据网格控件的代码
从gridview控件导出到excel文件(它遍布整个网络,如果请求可以发布)

我收到错误。

类型''GridView''的控件''gvSearch''必须放在带有runat = server的表单标签内。这个错误类似于数据网格有服务器端控件(如编辑按钮等)时所遇到的错误,但我的gridview非常简单,只显示文本字段(它当然在一个带有runat = server的表单
标签内。

是否有任何调整可以让代码工作?或者是一种完全不同的方法吗?

干杯,
克里斯
Hi,

I''m trying to export from a gridview control, to an excel file using code
intended for a datagrid control (it''s all over the web, can post if
requested)

I get the error.

Control ''gvSearch'' of type ''GridView'' must be placed inside a form tag
with runat=server.

This error is similar to that experienced when the datagrid had
server-side controls such as edit buttons and the like, but my gridview is
very plain, just displaying text fields (and it is of course inside a form
tag with runat=server).

Are there any tweaks that could be made to allow the code to work? or is a
completely different method the only way?

Cheers,
Chris



牛仔( Gregory A. Beamer写道:
Cowboy (Gregory A. Beamer) wrote:
查看标签。你的'会看起来像这样:

< / form>
< asp:GridView id =" gvSearch" RUNAT = QUOT;服务器" />

只需确保在< / form>内部移动GridView标记。标签。如果
还有其他元素在标记之外,那么也必须在GridView之上,也可以将它们拉出来。
Look at the tags. Your''s will look something like this:

</form>
<asp:GridView id="gvSearch" runat="server" />

Just make sure you move the GridView tag up inside of the </form> tag. If
there are other elements that are outside the tag, that also have to be
above the GridView, pull them up as well.




谢谢,但是我的代码并非如此,gridview(事实上几乎整个页面都是b $ b)都在< form>范围内。标签。


还有其他想法吗?我猜你的回答是没有理由

因为这不能在asp.net 2.0下工作?


干杯,

Chris



Thanks, but that it not the case with my code, the gridview (in fact
pretty much the whole page) is within the <form> tags.

Any other ideas? I''m guessing from your response that there''s no reason
for this not to work under asp.net 2.0?

Cheers,
Chris


>还有其他想法吗?我猜你的回答是没有理由不在asp.net 2.0下工作吗?


确保所有标签都正确关闭,验证html。


如果表格中有未封闭的标签,可能会发生奇怪的结果:ruant = server

和datagrid / gridview内部。


PL。
> 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.

PL.


这篇关于导出到Excel - ASP.net 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆