求助:请高手帮忙看看问题出在哪里
更新时没有得到 CommontName、Alias 、Overview、Record 的值<asp:DataList ID="DataList1" runat="server"
Width="100%" oneditcommand="DataList1_EditCommand"
onupdatecommand="DataList1_UpdateCommand" DataKeyField="Id">
<ItemTemplate>
<table style=" width:98%; border:0px;">
<tr>
<td><font color="gray">品名:</font></td>
</tr>
<tr>
<td>
<font color="gray"><asp:Label ID="Label2" runat="server" Text='<%# Eval("CommontName") %>' /></font>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td><font color="gray">别名:</font></td>
</tr>
<tr>
<td>
<font color="gray"><asp:Label ID="Label3" runat="server" Text='<%# Eval("Alias") %>' /></font>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td><font color="gray">概述:</font></td>
</tr>
<tr>
<td>
<font color="gray"><asp:Label ID="Label4" runat="server" Text='<%# Eval("Overview") %>' /></font>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td>
<font color="gray"><asp:Label ID="Label5" runat="server" Text='<%# Eval("Record") %>' /></font>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="left">
<asp:LinkButton CommandName="Edit" ID="Edit_But" ForeColor="#003366" runat="server">编辑</asp:LinkButton>
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table style=" width:98%; border:0px;">
<tr>
<td>
<font color="gray">品名:</font>
<font color="gray">
<asp:TextBox ID="txtName" runat="server" Text='<%# Bind("CommontName") %>'></asp:TextBox>
</font>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td>
<font color="gray">别名:</font>
<font color="gray"><asp:TextBox ID="txtAlias" runat="server" Text='<%# Bind("Alias") %>' /></font>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td>
<font color="gray">概述:</font>
<font color="gray"><asp:TextBox ID="txtOverView" runat="server" Text='<%# Bind("Overview") %>' /></font>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td>
<font color="gray">详细信息:</font>
<font color="gray">
<FTB:FreeTextBox ID="ftbRecord" runat="server" Text='<%# Bind("Record") %>'>
</FTB:FreeTextBox>
</font>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="left" bgcolor="#E8F0F7">
<asp:LinkButton ID="LinkButton1" runat="server"
CommandName="Update" ForeColor="#003366">更新</asp:LinkButton>
</td>
</tr>
</table>
</EditItemTemplate>
</asp:DataList>
后台代码:
//点击编辑
protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
this.DataList1.EditItemIndex = e.Item.ItemIndex;
this.DataList1.DataBind();
}
//点击修改
protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
{
Varieties model = new Varieties();
= ((TextBox)e.Item.FindControl("txtName")).Text.Trim();
model.Alias = ((TextBox)e.Item.FindControl("txtAlias")).Text.Trim();
model.Overview = ((TextBox)e.Item.FindControl("txtOverView")).Text.Trim();
model.Record = ((FreeTextBox)e.Item.FindControl("ftbRecord")).Text.Trim();
model.Id = (int)this.DataList1.DataKeys[e.Item.ItemIndex];
if (varietiesMessage.modifyVarietes(model))
{
Response.Write("<script>alert('操作成功!');window.location.href='Varietie.aspx';</script>");
}
else
{
Response.Write("<script>alert('服务器繁忙请稍候执行此操作!');</script>");
}
}