編輯商品信息屬於管理功能
Response
二
(注意
[html] <EditItemTemplate>
<table cellpadding=
<tr>
<td height=
</td>
<td height=
</td>
<td height=
</td>
<td height=
</td>
<td height=
</td>
</tr>
<tr>
<td width=
</td>
<td rowspan=
<asp:Image ID=
ImageUrl=
<td width=
</td>
<td colspan=
<asp:FileUpload ID=
<asp:Button ID=
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
商品類別
<td width=
<asp:DropDownList ID=
AutoPostBack=
OnSelectedIndexChanged=
</asp:DropDownList>
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
商品名稱
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
商品價格
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
商品描述
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
供應時間
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
供應日期
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
供應地區
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td height=
</td>
<td height=
</td>
<td height=
</td>
<td height=
</td>
<td height=
<asp:LinkButton ID=
<asp:LinkButton ID=
</td>
</tr>
</table>
</EditItemTemplate>
<EditItemTemplate>
<table cellpadding=
<tr>
<td height=
</td>
<td height=
</td>
<td height=
</td>
<td height=
</td>
<td height=
</td>
</tr>
<tr>
<td width=
</td>
<td rowspan=
<asp:Image ID=
ImageUrl=
<td width=
</td>
<td colspan=
<asp:FileUpload ID=
<asp:Button ID=
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
商品類別
<td width=
<asp:DropDownList ID=
AutoPostBack=
OnSelectedIndexChanged=
</asp:DropDownList>
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
商品名稱
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
商品價格
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
商品描述
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
供應時間
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
供應日期
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td width=
</td>
<td width=
</td>
<td width=
供應地區
<td width=
<asp:TextBox ID=
</td>
</tr>
<tr>
<td height=
</td>
<td height=
</td>
<td height=
</td>
<td height=
</td>
<td height=
<asp:LinkButton ID=
<asp:LinkButton ID=
</td>
</tr>
</table>
</EditItemTemplate>
三
代碼頁的主任是讀取前台窗體的值
[csharp] using System;
using System
using System
using System
using WestGarden
using WestGarden
namespace WestGarden
{
public partial class ItemManageControl : System
{
private static IList<ItemDetails> itemdetails = new List<ItemDetails>()
protected void Page_Load(object sender
{
if (!IsPostBack)
{
BindFormView()
ViewState[
ViewState[
}
}
protected void fvwItemDetails_ModeChanging(object sender
{
switch (e
{
case FormViewMode
this
BindFormView()
DropDownList ddl = (DropDownList)fvwItemDetails
BindDropDownList(ddl)
break;
case FormViewMode
this
BindFormView()
break;
default:
break;
}
}
protected void fvwItemDetails_PreRender(object sender
{
}
protected void ddlCategories_SelectedIndexChanged(object sender
{
DropDownList ddl = (DropDownList)fvwItemDetails
ViewState[
}
protected void btnUpload_Click(object sender
{
FileUpload fup = (FileUpload)fvwItemDetails
if (fup
{
fup
Image img = (Image)fvwItemDetails
img
ViewState[
}
else
{
Response
}
}
protected void fvwItemDetails_ItemUpdating(object sender
{
if (ViewState[
{
itemdetails[
}
if (ViewState[
{
DropDownList ddl = (DropDownList)fvwItemDetails
itemdetails[
}
TextBox txtname = (TextBox)fvwItemDetails
itemdetails[
TextBox txtPrice = (TextBox)fvwItemDetails
itemdetails[
TextBox txtDescn = (TextBox)fvwItemDetails
itemdetails[
TextBox txtSupplyTime = (TextBox)fvwItemDetails
itemdetails[
TextBox txtSupplyDate = (TextBox)fvwItemDetails
itemdetails[
TextBox txtSupplyArea = (TextBox)fvwItemDetails
itemdetails[
Item item = new Item()
item
fvwItemDetails
BindFormView()
ViewState[
ViewState[
}
private void BindFormView()
{
int itemKey = int
Item item = new Item()
itemdetails = item
fvwItemDetails
fvwItemDetails
}
private void BindDropDownList(DropDownList ddl)
{
ddl
ddl
ddl
ddl
string selectcategory = Request
if (selectcategory != null)
{
ListItem selectedItem = ddl
if (selectedItem != null)
selectedItem
}
}
}
}
using System;
using System
using System
using System
using WestGarden
using WestGarden
namespace WestGarden
{
public partial class ItemManageControl : System
{
private static IList<ItemDetails> itemdetails = new List<ItemDetails>()
protected void Page_Load(object sender
{
if (!IsPostBack)
{
BindFormView()
ViewState[
ViewState[
}
}
protected void fvwItemDetails_ModeChanging(object sender
{
switch (e
{
case FormViewMode
this
BindFormView()
DropDownList ddl = (DropDownList)fvwItemDetails
BindDropDownList(ddl)
break;
case FormViewMode
this
BindFormView()
break;
default:
break;
}
}
protected void fvwItemDetails_PreRender(object sender
{
}
protected void ddlCategories_SelectedIndexChanged(object sender
{
DropDownList ddl = (DropDownList)fvwItemDetails
ViewState[
}
protected void btnUpload_Click(object sender
{
FileUpload fup = (FileUpload)fvwItemDetails
if (fup
{
fup
Image img = (Image)fvwItemDetails
img
ViewState[
}
else
{
Response
}
}
protected void fvwItemDetails_ItemUpdating(object sender
{
if (ViewState[
{
itemdetails[
}
if (ViewState[
{
DropDownList ddl = (DropDownList)fvwItemDetails
itemdetails[
}
TextBox txtname = (TextBox)fvwItemDetails
itemdetails[
TextBox txtPrice = (TextBox)fvwItemDetails
itemdetails[
TextBox txtDescn = (TextBox)fvwItemDetails
itemdetails[
TextBox txtSupplyTime = (TextBox)fvwItemDetails
itemdetails[
TextBox txtSupplyDate = (TextBox)fvwItemDetails
itemdetails[
TextBox txtSupplyArea = (TextBox)fvwItemDetails
itemdetails[
Item item = new Item()
item
fvwItemDetails
BindFormView()
ViewState[
ViewState[
}
private void BindFormView()
{
int itemKey = int
Item item = new Item()
itemdetails = item
fvwItemDetails
fvwItemDetails
}
private void BindDropDownList(DropDownList ddl)
{
ddl
ddl
ddl
ddl
string selectcategory = Request
if (selectcategory != null)
{
ListItem selectedItem = ddl
if (selectedItem != null)
selectedItem
}
}
}
}
四
[csharp] public void UpdateItem(ItemDetails item)
{
SqlParameter[] parms;
parms = new SqlParameter[]
{
new SqlParameter(
new SqlParameter(
new SqlParameter(
new SqlParameter(
new SqlParameter(
new SqlParameter(
new SqlParameter(
new SqlParameter(
new SqlParameter(
};
parms[
parms[
parms[
parms[
parms[
parms[
parms[
parms[
parms[
SqlHelper
}
From:http://tw.wingwit.com/Article/program/net/201311/13076.html