读书人

DataList的编辑 更新不了啊 感觉D

发布时间: 2013-04-09 16:45:09 作者: rapoo

DataList的编辑 更新不了啊~~ 感觉DataList的UpdateCommand写的不对 我太笨了~~~~~~~~~~`晕了
本帖最后由 chase_wang 于 2013-04-06 20:23:54 编辑 前台


<%@ Page Language="C#" MasterPageFile="~/AdminMasterPage.master" AutoEventWireup="true" CodeFile="UserAdmin.aspx.cs" Inherits="BPage_UserAdmin" Title="用户管理" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style2
{
width: 100%;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


<div style="height: 530px; width:100%; position:absolute; left:0px; z-index:2; overflow:scroll" >
<asp:DataList ID="DataList" runat="server"
Width="100%" onitemcommand="DataList_ItemCommand"
onitemdatabound="DataList_ItemDataBound" BackColor="LightGoldenrodYellow"
BorderColor="Tan" BorderWidth="1px" CellPadding="2"
ForeColor="Black" DataKeyField="id"
ondeletecommand="DataList_DeleteCommand"
oneditcommand="DataList_EditCommand"
onupdatecommand="DataList_UpdateCommand"
oncancelcommand="DataList_CancelCommand">


<HeaderStyle BackColor="Tan" Font-Bold="True" />

<ItemTemplate>

<table width="100%" border="1">
<tr>
<td align="left"><asp:Label ID="LB_id" runat="server" Text='<%#Eval("id")%>'></asp:Label></td>
<td align="left">等级<asp:Label ID="LB_userlevel" runat="server" Text='<%#Eval("userlevel")%>'></asp:Label></td>
<td align="left">编码<asp:Label ID="TB_usercode" runat="server" Text='<%#Eval("usercode")%>'></asp:Label></td>


<td align="center"><asp:LinkButton ID="LKB_edit" runat="server" CommandName="Edit">编辑</asp:LinkButton></td>
</tr>
<tr>
<td align="left">客户<asp:Label ID="TB_username" runat="server" Text='<%#Eval("username")%>'></asp:Label></td>
<td align="left">密码<asp:Label ID="TB_userpsw" runat="server" Text='<%#Eval("userpsw")%>'></asp:Label></td>
<td align="left">手机<asp:Label ID="TB_phone" runat="server" Text='<%#Eval("phone")%>'></asp:Label></td>
<td align="center"><asp:LinkButton ID="LKB_delete" runat="server" CommandName="Delete">删除</asp:LinkButton></td>
</tr>
<tr>
<td colspan="4" align="left">地址<asp:Label ID="TB_place" runat="server" Text='<%#Eval("place")%>'></asp:Label></td>

</tr>
</table>


</ItemTemplate>

<AlternatingItemStyle BackColor="PaleGoldenrod" />
<FooterStyle BackColor="Tan" />
<FooterTemplate>
<div style="text-align: center">
<table id="Page" border="0" cellpadding="0" cellspacing="0" style="font-size: 12px; ">
<tr>


<td >
<asp:Label ID="labCurrentPage" runat="server"></asp:Label>/
<asp:Label ID="labPageCount" runat="server"></asp:Label>
<asp:LinkButton ID="lnkbtnFirst" runat="server" CommandName="first" Font-Underline="False"
ForeColor="Black">首页</asp:LinkButton>
<asp:LinkButton ID="lnkbtnFront" runat="server" CommandName="pre" Font-Underline="False"
ForeColor="Black">上一页</asp:LinkButton>
<asp:LinkButton ID="lnkbtnNext" runat="server" CommandName="next" Font-Underline="False"
ForeColor="Black">下一页</asp:LinkButton>
<asp:LinkButton ID="lnkbtnLast" runat="server" CommandName="last" Font-Underline="False"
ForeColor="Black">尾页</asp:LinkButton>
   跳转至:<asp:TextBox ID="txtPage" runat="server" Width="35px" Height="21px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" CommandName="search" Text="GO"
Height="19px" />
<br />
</td>
</tr>
</table>


</div>
</FooterTemplate>



<EditItemTemplate>
<table width="100%" border="1">
<tr>
<td align="left"><asp:Label ID="LB_id1" runat="server" Text='<%#Eval("id")%>'></asp:Label></td>
<td align="left">等级<asp:TextBox ID="TB_level" runat="server" Text='<%#Eval("userlevel")%>'></asp:TextBox></td>
<td align="left">编码<asp:TextBox ID="TB_usercode" runat="server" Text='<%#Eval("usercode")%>'></asp:TextBox></td>
<td align="center"><asp:LinkButton ID="LKB_keep" runat="server" CommandName="Update">保存</asp:LinkButton></td>
</tr>
<tr>
<td align="left">客户<asp:TextBox ID="TB_username" runat="server" Text='<%#Eval("username")%>'></asp:TextBox></td>
<td align="left">密码<asp:TextBox ID="TB_userpsw" runat="server" Text='<%#Eval("userpsw")%>'></asp:TextBox></td>
<td align="left">手机<asp:TextBox ID="TB_phone" runat="server" Text='<%#Eval("phone")%>'></asp:TextBox></td>
<td align="center"><asp:LinkButton ID="LKB_cancle" runat="server" CommandName="Cancel">取消</asp:LinkButton></td>
</tr>
<tr>
<td align="left">密码<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("userpsw")%>'></asp:TextBox></td>


<td colspan="4" align="left">地址<asp:TextBox ID="TB_place" runat="server" Width="80%"
TextMode="MultiLine" Font-Size="Large" Font-Bold="True"></asp:TextBox></td>

</tr>
</table>
</EditItemTemplate>



<SelectedItemStyle BackColor="#B22222" ForeColor="GhostWhite" />

</asp:DataList>


</div>

</asp:Content>











[解决办法]
不管你的问题出在哪里,你把握一点:“不要胡乱Bind数据库”这就能迅速发现你所编写asp.net程序的bug。

读书人网 >asp.net

热点推荐