日期:2014-05-19  浏览次数:20493 次

datalist的手写代码更新记录的怪问题?
昨天做 "datalist的手写代码更新记录 "的时候遇到一个难题:就是运行后更改了数据按了更新按钮,数据还是没有更

改,找了一个下午也没能找出那里错了,试过在protected   void   DataList1_UpdateCommand(object   source,  

DataListCommandEventArgs   e)事件的最后一个花括号}处加了一个断点来调试(也就是说在55行加了一个断点),发

现string   Score   =((   TextBox)e.Item.FindControl( "TextBox1 ")).Text和string   Comment   =   ((TextBox)

e.Item.FindControl( "TextBox2 ")).Text的值是原来没有更新之前的值,而不是更新之后的值,真的很奇怪!请各位

帮忙看一下错在那里.

075010.aspx


  1 <%@   Page   Language= "C# "   AutoEventWireup= "true "   CodeFile= "070510.aspx.cs "   Inherits= "_070510 "   %>
  2
  3 <!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "  

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
  4
  5 <html   xmlns= "http://www.w3.org/1999/xhtml "   >
  6 <head   runat= "server ">
  7         <title> Untitled   Page </title>
  8 </head>
  9 <body>
10         <form   id= "form1 "   runat= "server ">
11         <div>
12                 <asp:DataList   ID= "DataList1 "   runat= "server "   OnCancelCommand= "DataList1_CancelCommand "  

OnEditCommand= "DataList1_EditCommand "   OnUpdateCommand= "DataList1_UpdateCommand ">
13                         <ItemTemplate>
14                                 <asp:LinkButton   ID= "LinkButton1 "   runat= "server "   CommandName= "edit "> 修改

</asp:LinkButton>
15
16                                 <asp:LinkButton   ID= "LinkButton2 "   runat= "server "   CommandName= "delete "> 删除

</asp:LinkButton>
17
18                         <%#   Eval( "HomeworkID ")%>
19
20                         <%#   Eval( "HScore ")%>
21
22                         <%#   Eval( "HComment ")%>
23                         </ItemTemplate>
24                         <EditItemTemplate>
25                                 <asp:LinkButton   ID= "LinkButton1 "   runat= "server "   CommandName= "update "> 更新

</asp:LinkButton>
26
27                                 <asp:LinkButton   ID= "LinkButton2 &qu