前台:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewTest.aspx.cs" Inherits="Sale_GridViewTest" %>
<%@ Register Assembly="SmartGridView" Namespace="SmartGridView" TagPrefix="cc1" %>
<!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>Test GridView</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<cc1:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="ObjectDataSource1" Width="1000px">
<Columns>
<asp:BoundField DataField="no" HeaderText="序号" SortExpression="no" />
<asp:BoundField DataField="name" HeaderText="名称" SortExpression="name" />
<asp:BoundField DataField="no" HeaderText="序号" SortExpression="no" />
<asp:BoundField DataField="name" HeaderText="名称" SortExpression="name" />
<asp:BoundField DataField="no" HeaderText="序号" SortExpression="no" />
<asp:BoundField DataField="name" HeaderText="名称" SortExpression="name" />
<asp:BoundField DataField="no" HeaderText="序号" SortExpression="no" />
<asp:BoundField DataField="name" HeaderText="名称" SortExpression="name" />
<asp:BoundField DataField="no" HeaderText="序号" SortExpression="no" />
<asp:BoundField DataField="name" HeaderText="名称" SortExpression="name" />
</Columns>
<FixRowCol FixColumnIndices="0,1" FixRowIndices="0" IsFixHeader="True" TableHeight="300px"
TableWidth="300px" EnableScrollState="true" />
</cc1:SmartGridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="Select"
TypeName="OjbData"></asp:ObjectDataSource>
</div>
</form>
</body>
</html>
*********************************************************
后台:需要新建一个类
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
/**/
/// <summary>
/// OjbData 的摘要说明
/// </summary>
public class OjbData
{
public OjbData()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
[DataObjectMethod(DataObjectMethodType.Select, true)]
public DataTable Select()
{
DataTable dt = new DataTable();
dt.Columns.Add("no", typeof(string));
dt.Columns.Add("name", typeof(string));
for (int i = 0; i < 30; i++)
{
DataRow dr = dt.NewRow();
dr[0] = "no" + i.ToString().PadLeft(2, '0');
dr[1] = "name" + i.ToString().PadLeft(2, '0');
dt.Rows.Add(dr);
}
return dt;
}
}