Default.aspx
<%......@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
![]()
Inherits="_Default" %>
![]()
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
![]()
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>SmartGridView测试</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<yyc:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False"
![]()
DataSourceID="ObjectDataSource1">
<Columns>
<asp:TemplateField ItemStyle-Width="50px">
<headertemplate>
<asp:Button id="btnExportToExcel" runat="server" Text="Excel" CommandName="ExportToExcel"
![]()
CommandArgument="ExcelFileName;5,6" />
</headertemplate>
<itemtemplate>
<%......# Container.DataItemIndex + 1 %>
</itemtemplate>
</asp:TemplateField>
<asp:BoundField DataField="no" HeaderText="序号" SortExpression="no" ItemStyle-
![]()
Width="100px" />
<asp:BoundField DataField="name" HeaderText="名称" SortExpression="name" ItemStyle-
![]()
Width="100px" />
<asp:BoundField DataField="no" HeaderText="序号" SortExpression="no" ItemStyle-
![]()
Width="100px" />
<asp:BoundField DataField="name" HeaderText="名称" SortExpression="name" ItemStyle-
![]()
Width="100px" />
<asp:BoundField DataField="no" HeaderText="序号" SortExpression="no" ItemStyle-
![]()
Width="100px" />
<asp:BoundField DataField="name" HeaderText="名称" SortExpression="name" ItemStyle-
![]()
Width="100px" />
</Columns>
</yyc:SmartGridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="Select"
TypeName="OjbData"></asp:ObjectDataSource>
</div>
</form>
</body>
</html>
![]()
注:为了防止出错要在.cs代码中加上下面这句
public override void VerifyRenderingInServerForm(Control control)
![]()
...{
![]()
}
另外,如果你的GridView中含有命令按钮的话要在.aspx页面的头部中加上下面这个属性
EnableEventValidation="false"
