http://blog.csdn.net/goodyatou/article/details/4372617
解决方案 »
- asp.net中listview怎么用的??
- 如何让HTML支持内置标签{PE}
- 困扰了一天的问题 sqldatasource
- 使用gridview 删除报索引超出范围(内附全代码)
- 关于windwos.open 的问题
- 以前做的一个网站源代码丢失了,现在只有编译过的程序.想要进行修改,有办法吗?
- 接口实现问题
- 好的杭州软件公司用asp.net的
- 100 可以给个 asp.net的比较全的 自助建站 系统我 研究一下啊```+讨论
- 打算做一个XML论坛,不知道性能会不会更优与MSSQL呢?
- 程序集“Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”中的类型“Model.Jxs_
- 出了些问题 找了半天没找到 新手 求教~
好用是好用,但自己改过来,太难
还没试过多行表头能不能定住有源码么?
//固定表头设置
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="#DEBA84"
BorderColor="#DEBA84" BorderStyle="None"
BorderWidth="1px" CellPadding="3" CellSpacing="2" DataKeyNames="产品编号"
ShowFooter="True" Width="624px"
OnRowCreated="GridView1_RowCreated" OnRowDataBound="GridView1_RowDataBound"
onpageindexchanging="GridView1_PageIndexChanging" PageSize="5">
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<Columns>
<asp:TemplateField HeaderText="产品名称">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("产品") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="单价" HeaderText="单价" SortExpression="单价" />
<asp:BoundField DataField="库存量" HeaderText="库存量" SortExpression="库存量" />
<asp:BoundField DataField="已订购量" HeaderText="已订购量" SortExpression="已订购量" />
<asp:TemplateField HeaderText="订货金额" SortExpression="订货金额">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("订货金额", "{0:c}") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="OrderTotalLabel" runat="server" Font-Underline="True" ForeColor="Red"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("订货金额", "{0:c}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="订单日期">
<EditItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("订单日期","{0:d}") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("订单日期","{0:d}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#C0FFC0" Font-Bold="True" ForeColor="Black" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>
//cs页面绑定gridview绑定控件显示数据
//公共类设置
public static void GridViewDataBind(GridView gridview, DataTable table)
{
//记录为空重新构造Gridview
if (table.Rows.Count == 0)
{
table = table.Clone();
table.Rows.Add(table.NewRow());
gridview.DataSource = table;
gridview.DataBind();
int columnCount = table.Columns.Count;
gridview.Rows[0].Cells.Clear();
gridview.Rows[0].Cells.Add(new TableCell());
gridview.Rows[0].Cells[0].ColumnSpan = columnCount;
gridview.Rows[0].Cells[0].Text = EmptyText;
gridview.Rows[0].Cells[0].Style.Add("text-align", "center");
}
else
{
//数据不为空直接绑定
gridview.DataSource = table;
gridview.DataBind();
}
//重新绑定取消选择
gridview.SelectedIndex = -1;
}//查询显示数据
protected void btnSearch_Click(object sender, EventArgs e)
{
string sqlstr = "select 产品编号, 产品, 单价, 库存量, 已订购量, 订单日期,单价 * 已订购量 AS 订货金额 from tb_OrderForm where 产品 like '%" + tbSearch.Text + "%'";
DataTable dt= sd.GetDataTable(sqlstr);//创建DataTable对象
if (dt.Rows.Count > 0)//如果有数据
{
this.GridView1.DataSource = dt;//将dt对象作为数据源
this.GridView1.DataBind();//绑定数据
}
else//如果数据源或查询数据为空
{
GridviewControl.GridViewDataBind(GridView1, dt);//调用GridViewDataBind()方法实现显示表头和提示信息
}
}
//固定表头设置
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="#DEBA84"
BorderColor="#DEBA84" BorderStyle="None"
BorderWidth="1px" CellPadding="3" CellSpacing="2" DataKeyNames="产品编号"
ShowFooter="True" Width="624px"
OnRowCreated="GridView1_RowCreated" OnRowDataBound="GridView1_RowDataBound"
onpageindexchanging="GridView1_PageIndexChanging" PageSize="5">
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<Columns>
<asp:TemplateField HeaderText="产品名称">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("产品") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="单价" HeaderText="单价" SortExpression="单价" />
<asp:BoundField DataField="库存量" HeaderText="库存量" SortExpression="库存量" />
<asp:BoundField DataField="已订购量" HeaderText="已订购量" SortExpression="已订购量" />
<asp:TemplateField HeaderText="订货金额" SortExpression="订货金额">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("订货金额", "{0:c}") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="OrderTotalLabel" runat="server" Font-Underline="True" ForeColor="Red"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("订货金额", "{0:c}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="订单日期">
<EditItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("订单日期","{0:d}") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("订单日期","{0:d}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#C0FFC0" Font-Bold="True" ForeColor="Black" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>
//cs页面绑定gridview绑定控件显示数据
//公共类设置
public static void GridViewDataBind(GridView gridview, DataTable table)
{
//记录为空重新构造Gridview
if (table.Rows.Count == 0)
{
table = table.Clone();
table.Rows.Add(table.NewRow());
gridview.DataSource = table;
gridview.DataBind();
int columnCount = table.Columns.Count;
gridview.Rows[0].Cells.Clear();
gridview.Rows[0].Cells.Add(new TableCell());
gridview.Rows[0].Cells[0].ColumnSpan = columnCount;
gridview.Rows[0].Cells[0].Text = EmptyText;
gridview.Rows[0].Cells[0].Style.Add("text-align", "center");
}
else
{
//数据不为空直接绑定
gridview.DataSource = table;
gridview.DataBind();
}
//重新绑定取消选择
gridview.SelectedIndex = -1;
}//查询显示数据
protected void btnSearch_Click(object sender, EventArgs e)
{
string sqlstr = "select 产品编号, 产品, 单价, 库存量, 已订购量, 订单日期,单价 * 已订购量 AS 订货金额 from tb_OrderForm where 产品 like '%" + tbSearch.Text + "%'";
DataTable dt= sd.GetDataTable(sqlstr);//创建DataTable对象
if (dt.Rows.Count > 0)//如果有数据
{
this.GridView1.DataSource = dt;//将dt对象作为数据源
this.GridView1.DataBind();//绑定数据
}
else//如果数据源或查询数据为空
{
GridviewControl.GridViewDataBind(GridView1, dt);//调用GridViewDataBind()方法实现显示表头和提示信息
}
}
$(function() {
$("#GridView1").toSuperTable({ width: "640px", height: "480px", fixedCols: 2 })
.find("tr:even").addClass("altRow");
});
所以好奇了一下,我先试试能不能多行冻结