ReorderList的Edit如何使用

来源:互联网 发布:搜空地雷升级数据 编辑:程序博客网 时间:2024/05/30 04:26

项目中使用到了Asp.net Ajax4.0中的一个控件——RecordList。

模板中有EditTemplate,但是例子中仅有一个添加模板AddTemplae,网上查了半天也没查到。只好自己在模板里找了一下,现在写出来,方便有同样问题的人。


这个触发编辑的按钮放在ItemTemplate中

   <ItemTemplate>      <div class="itemArea">        <asp:Label ID="Label1" runat="server" Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("Title"))) %>' />        <asp:Label ID="Label2" runat="server" Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("Description", " - {0}"))) %>' />        <asp:Button ID="Button1" runat="server" CommandName="Edit" Text="Edit" />       </div>    </ItemTemplate>

那个lable1和label2就不要管了,就是一个绑定,重要的是那个button,这样,点击button时就能触发编辑事件了。


样子就是这个样子,点击Edit时,就触发了编辑事件,编辑模式下展示的样子,就是在编辑模板下修改 EditTemplate下修改

    <EditItemTemplate>        <div class="itemArea">          <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Title") %>' ValidationGroup="edit" />          <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Description") %>' ValidationGroup="edit" />          <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Priority") %>' ValidationGroup="edit" />          <asp:Button ID="btn_update" runat="server" Text="update" CommandName="Update" />          <asp:Button ID="btn_cancle" runat="server" Text="cancel" CommandName="Cancel" />        </div>   </EditItemTemplate>



这样就实现了编辑的功能。


剩下的功能,就都可以在网上查到了。

俺举一反三的能力太弱,应该不适合当程序员……


原创粉丝点击