设置DataGrid 的 AutoGenerateColumns="False",然后使用 <asp:BoundColumn>
<asp:datagrid id="DataGrid1" runat="server" BorderWidth="1px" BorderColor="Black" Font-Size="12pt"
AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-BackColor="#aaaadd" PagerStyle-HorizontalAlign="Right"
CellPadding="3" AllowPaging="True" AllowCustomPaging="True" AutoGenerateColumns="False" OnPageIndexChanged="MyDataGrid_Page"
PageSize="15" AllowSorting="True" OnSortCommand="DataGrid1_SortCommand">
<AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>
<ItemStyle Font-Size="Smaller" BorderWidth="22px"></ItemStyle>
<HeaderStyle BackColor="#AAAADD"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="ID" SortExpression="ID" HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="订单ID" HeaderText="订单ID"></asp:BoundColumn>
<asp:BoundColumn DataField="产品ID" HeaderText="产品ID"></asp:BoundColumn>
<asp:BoundColumn DataField="单价" HeaderText="单价"></asp:BoundColumn>
<asp:BoundColumn DataField="数量" HeaderText="数量"></asp:BoundColumn>
<asp:BoundColumn DataField="折扣" HeaderText="折扣"></asp:BoundColumn>
</Columns>
<PagerStyle Font-Names="VerDana" Font-Bold="True" HorizontalAlign="Right" ForeColor="Coral"
Mode="NumericPages"></PagerStyle>
</asp:datagrid>
<asp:datagrid id="DataGrid1" runat="server" BorderWidth="1px" BorderColor="Black" Font-Size="12pt"
AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-BackColor="#aaaadd" PagerStyle-HorizontalAlign="Right"
CellPadding="3" AllowPaging="True" AllowCustomPaging="True" AutoGenerateColumns="False" OnPageIndexChanged="MyDataGrid_Page"
PageSize="15" AllowSorting="True" OnSortCommand="DataGrid1_SortCommand">
<AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>
<ItemStyle Font-Size="Smaller" BorderWidth="22px"></ItemStyle>
<HeaderStyle BackColor="#AAAADD"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="ID" SortExpression="ID" HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="订单ID" HeaderText="订单ID"></asp:BoundColumn>
<asp:BoundColumn DataField="产品ID" HeaderText="产品ID"></asp:BoundColumn>
<asp:BoundColumn DataField="单价" HeaderText="单价"></asp:BoundColumn>
<asp:BoundColumn DataField="数量" HeaderText="数量"></asp:BoundColumn>
<asp:BoundColumn DataField="折扣" HeaderText="折扣"></asp:BoundColumn>
</Columns>
<PagerStyle Font-Names="VerDana" Font-Bold="True" HorizontalAlign="Right" ForeColor="Coral"
Mode="NumericPages"></PagerStyle>
</asp:datagrid>
解决方案 »
- 谁有可以正确运行的Yonkly微博
- 求ASP.NET的上传文件到FTP里面的完整代码包括前台页面代码和后台CS里面的代码
- cache 缓存中移除项时通知应用程序的方法 中httpcontext 为 null 怎么处理
- axWebBrowser窗口显示
- Gridview下的DropDownList问题,很郁闷.
- 怎样获取在GRIDVIEW模版列里的INPUT (html text) 控件的值??
- 为什么我点下WEB控件(button)就会重新载入一次页面啊??
- 我从asp转过来的,做第一个asp.net(C#)项目的感受
- asp.net中cookie的处理
- datagrid 分页出的一个错误??
- 一个关于调试的问题
- 急急急!为何可以将WEB控件拖到panel控件里,却无法拖到table控件里?
2003/09/01.???
给你一个函数
//把字符串年月日后面的时间去除,也可用于带空格的其它字符串
public static string changeString(string ss)
{
string lkk="";
for(int i=ss.Length;i>0;i--)
{
char lk=ss[i-1];
if(lk==' ')
{
lkk=ss.Substring(0,i);
break;
}
}
return lkk;
}
<asp:datagrid id="MyDataGrid" runat="server" AutoGenerateColumns="False" HorizontalAlign="Center" ItemStyle-ForeColor="#cccccc"
AlternatingItemStyle-BackColor="#f5f5f5" HeaderStyle-BackColor="#F6F6F6" Font-Size="11pt" Font-Name="Verdana" CellSpacing="0" CellPadding="3"
GridLines="Both" BorderWidth="1" BorderColor="#D1D1D1" OnPageIndexChanged="MyDataGrid_Page" PagerStyle-HorizontalAlign="center" PagerStyle-Mode="NumericPages"
PageSize="20" AllowPaging="True">
<AlternatingItemStyle BackColor="#F6F6F6"></AlternatingItemStyle>
<HeaderStyle BackColor="#F6F6F6" Font-Bold="True" HorizontalAlign="Center" Height="30"></HeaderStyle>
<PagerStyle HorizontalAlign="center" Mode="NumericPages"></PagerStyle>
<Columns>
<asp:BoundColumn HeaderText="ID" DataField="Id" HeaderStyle-Width="60px" ItemStyle-Height="25" ItemStyle-HorizontalAlign="Center"></asp:BoundColumn>
<asp:BoundColumn HeaderText="b" DataField="b" HeaderStyle-Width="100px" ItemStyle-Height="25"
ItemStyle-ForeColor="#FF6600" ItemStyle-HorizontalAlign="Center" ></asp:BoundColumn>
<asp:BoundColumn HeaderText="c" DataField="c" HeaderStyle-Width="100px" ItemStyle-Height="25"
ItemStyle-ForeColor="#8FB127" ItemStyle-HorizontalAlign="Center" ></asp:BoundColumn>
</Columns>
</asp:datagrid
[02] specifying display properties of the DataGrid
[03] associate custom events with the DataGrid.
[04] provide custom sorting on the results of a DataGrid.
[05] use templates to further customize the DataGrid's appearance.
[06] use the DataGrid's built-in edit ing capabilities,
[07] customizing the editing interface using the EditItemTemplate .
[08] add client-side code to a ButtonColumn 's client-side onclick event.
[09] enhance the DataGrid's editing interface by having the editing interface's TextBox receive focus when the page is loaded.
[10] (automatically) add filter ing buttons so that one can filter the data in a DataGrid.
[11] create a DataGrid Web control with a column of related radio buttons .
[12] create a sort able DataGrid that can be sorted in ascending and descending order.
[13] sum up a DataGrid column and have the sum displayed in the footer .
[14] build a master/detail DataGrid.
[15] add paging support to the DataGrid!