圖書類別和圖書信息的管理()
圖書類別的編輯主要在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開發培訓視頻教程
From:http://tw.wingwit.com/Article/program/net/201311/15841.html