本次使用GridView是工厂模式下 无极限分类
GridView详解
1.GridView前台分析
2.GridView分页讲解
3.GridView绑定,编辑,更新,取消,删除,排序
GridView前台分析
//AllowSorting 是否排序
//PageSize 每页容纳的数据条数
//AutoGenerateColumns 是否要自动生成列几乎都设置成false 不需要GridView自带的列
//AllowPagig 是否分页
//onrowdeleting删除事件
//onrowupdating 更新事件是在编辑里的事件之一
//onrowediting 编辑事件还要有更新事件和取消事件
//onpageindexchanging页的索引改变
//onrowcancelingedit 取消事件是编辑里的事件之一
//onsorting 排序事件
<asp:GridView ID="gvwFenLei" runat="server"
AllowSorting="true" PageSize="5"
AllowPaging="True" onrowdeleting="gvwFenLei_RowDeleting"
onrowupdating="gvwFenLei_RowUpdating"
onrowcancelingedit="gvwFenLei_RowCancelingEdit"
onrowediting="gvwFenLei_RowEditing"
onpageindexchanging="gvwFenLei_PageIndexChanging"
onsorting="gvwFenLei_Sorting">
<Columns>//包含列
<asp:BoundField DataField="Id" HeaderText="编号" ReadOnly="true" SortExpression="Id"/>
<asp:BoundField DataField="ParentId" HeaderText="父级节点ID" SortExpression="ParentId" />
<asp:BoundField DataField="Name" HeaderText="名字" SortExpression="Name"/>
<asp:BoundField DataField="Depth" HeaderText="节点深度" SortExpression="Depth" />
<asp:BoundField DataField="Turn" HeaderText="顺序" SortExpression="Turn" />
<asp:BoundField DataField="PathWay" HeaderText="路径" SortExpression="PathWay" />//BoundField 字段绑定 DataField是数据表的 字段 HeaderText 显示字段名 SortExpression排序的字段
<asp:CommandField HeaderText="选择" ShowSelectButton="true" />
<asp:CommandField HeaderText="编辑" ShowEditButton="true" />
<asp:CommandField HeaderText="删除" ShowDeleteButton="true" />//按钮 以及对于的事件功能
</Columns>
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />//头样式
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />//尾样式
<SelectedRowStyle BackColor="#669999" ForeColor="White" />//选择行的样式
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Center" />//分页的样式 对应的gvwFenLei_PageIndexChanging事件 只要一句代码就行gvwFenLei.PageIndex = e.NewPageIndex; 不过还要记得绑定数据源 (在上篇的分页中就无需PagerStyle)
</asp:GridView>
GridView详解
1.GridView前台分析
2.GridView分页讲解
3.GridView绑定,编辑,更新,取消,删除,排序
GridView前台分析
//AllowSorting 是否排序
//PageSize 每页容纳的数据条数
//AutoGenerateColumns 是否要自动生成列几乎都设置成false 不需要GridView自带的列
//AllowPagig 是否分页
//onrowdeleting删除事件
//onrowupdating 更新事件是在编辑里的事件之一
//onrowediting 编辑事件还要有更新事件和取消事件
//onpageindexchanging页的索引改变
//onrowcancelingedit 取消事件是编辑里的事件之一
//onsorting 排序事件
<asp:GridView ID="gvwFenLei" runat="server"
AllowSorting="true" PageSize="5"
AllowPaging="True" onrowdeleting="gvwFenLei_RowDeleting"
onrowupdating="gvwFenLei_RowUpdating"
onrowcancelingedit="gvwFenLei_RowCancelingEdit"
onrowediting="gvwFenLei_RowEditing"
onpageindexchanging="gvwFenLei_PageIndexChanging"
onsorting="gvwFenLei_Sorting">
<Columns>//包含列
<asp:BoundField DataField="Id" HeaderText="编号" ReadOnly="true" SortExpression="Id"/>
<asp:BoundField DataField="ParentId" HeaderText="父级节点ID" SortExpression="ParentId" />
<asp:BoundField DataField="Name" HeaderText="名字" SortExpression="Name"/>
<asp:BoundField DataField="Depth" HeaderText="节点深度" SortExpression="Depth" />
<asp:BoundField DataField="Turn" HeaderText="顺序" SortExpression="Turn" />
<asp:BoundField DataField="PathWay" HeaderText="路径" SortExpression="PathWay" />//BoundField 字段绑定 DataField是数据表的 字段 HeaderText 显示字段名 SortExpression排序的字段
<asp:CommandField HeaderText="选择" ShowSelectButton="true" />
<asp:CommandField HeaderText="编辑" ShowEditButton="true" />
<asp:CommandField HeaderText="删除" ShowDeleteButton="true" />//按钮 以及对于的事件功能
</Columns>
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />//头样式
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />//尾样式
<SelectedRowStyle BackColor="#669999" ForeColor="White" />//选择行的样式
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Center" />//分页的样式 对应的gvwFenLei_PageIndexChanging事件 只要一句代码就行gvwFenLei.PageIndex = e.NewPageIndex; 不过还要记得绑定数据源 (在上篇的分页中就无需PagerStyle)
</asp:GridView>