图书类别和图书信息的管理()
图书类别的编辑主要在ST_PdClassaspx页面中处理
ST_PdClassaspx的主要HTML代码
ST_PdClassaspx的主要HTML代码如程序所示
程序 ST_PdClassaspx
<form id=Form method=post runat=server>
<TABLE id=Table cellPadding= width=% align=center
border=>
<TR><TD>
<input class=button id=btnAdd type=button value=添加子
类 name=btnAdd runat=server onserverclick=btnAdd_ServerClick>
<asp:button id=btnDel Width=px CssClass=button Text=
删除子类 Runat=server onclick=btnDel_Click></asp:button>
<asp:button id=btnEdit Width=px CssClass=button Text=
编辑子类 Runat=server onclick=btnEdit_Click></asp:button>
<asp:button id=IbtnAddProduct runat=server
CssClass=button Text=增加图书
onclick=IbtnAddProduct_Click></asp:button>
<asp:button id=btnDelProduct runat=server
CssClass=button Text=删除图书
onclick=btnDelProduct_Click></asp:button></TD>
</TR>
<TR>
<TD>图书列表
<asp:label id=lblNoGoods runat=server Visible=False
ForeColor=Red>目前该分类中没有图书!</asp:label>
<asp:textbox id=txtSearch runat=server
Visible=False></asp:textbox>
<asp:button id=btnSearch CssClass=button Text=搜索图书
Runat=server Visible=False></asp:button>
</TD></TR>
<TR>
<TD>
<!GridView控件>
<asp:GridView id=dgProduct runat=server
OnRowCommand=dgItem AllowPaging=True
AutoGenerateColumns=False BorderColor=#
BorderStyle=Double BorderWidth=px BackColor=White
CellPadding= GridLines=Horizontal>
<SelectedRowStyle FontBold=True ForeColor=White
BackColor=#></SelectedRowStyle>
<RowStyle BackColor=White
ForeColor=#></RowStyle>
<HeaderStyle FontBold=True ForeColor=White
BackColor=#></HeaderStyle>
<FooterStyle BackColor=White
ForeColor=#></FooterStyle>
<!列>
<Columns>
<asp:BoundField Visible=False
DataField=ST_ProductID HeaderText=图书ID></asp:BoundField>
<!模板列>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox Runat=server
ID=chkID></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField=ST_ProductName
HeaderText=图书名称></asp:BoundField>
<!模板列>
<asp:TemplateField HeaderText=图书图片>
<ItemTemplate>
<table cellSpacing= cellPadding=
width= border=>
<tr>
<td align=center valign=middle
width=>
<img height= src=<%#
GetImage(Eval(ST_Image)ToString())%>>
</td></tr>
</table>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField=ST_ClassID HeaderText=所
属类别 Visible=False></asp:BoundField>
<asp:TemplateField HeaderText=上下架操作>
<ItemTemplate>
<asp:Button CssClass=button Text=<%#
Eval(ST_IsSelling)ToString()==True?下架:上架%>
Runat=server CommandName=UpDown ID=Button>
</asp:Button>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=编辑>
<ItemTemplate>
<a href=<%#
ST_ProductAddaspx?Action=Edit&id= + Eval(ST_ProductID) +
&st_classid= + Eval(ST_ClassID)%> target=_blank>编辑</a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=删除>
<ItemTemplate>
<asp:Button CssClass=button Text=删除
Runat=server CommandName=del ID=btnProductDel></asp:Button>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField Visible=False
DataField=ST_IsSelling></asp:BoundField>
<!模板列>
<asp:TemplateField HeaderText=推荐>
<ItemTemplate>
<asp:Button CssClass=button Text=<%#
Eval(ST_IsPromotion)ToString()==True?取消推荐:置为推荐 %>
Runat=server CommandName=Pro ID=btnPro></asp:Button>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField
DataField=ST_IsPromotion></asp:BoundField>
</Columns>
<!分页样式>
<PagerSettings NextPageText=下一页
PreviousPageText=上一页 Mode=NextPrevious />
</asp:GridView>
</TD></TR>
</TABLE>
</form>
【代码说明】代码第~行是一个复杂的GridView其中第~行的模板列是一个复选框第~行的模板列通过调用后台方法GetImage()显示图书图片第~行实现上下架的操作第~行是编辑和删除按钮的模板列第~行是实现推荐功能的模板列
返回目录ASPNET项目开发指南
编辑推荐
ASPNET MVC 框架揭秘
ASPNET开发宝典
ASP NET开发培训视频教程