如何使用itemtemplate的项目文本框作为数据列表中的edititemtemplate [英] how to use itemtemplate's item textbox as the edititemtemplate in datalist

查看:104
本文介绍了如何使用itemtemplate的项目文本框作为数据列表中的edititemtemplate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用数据列表控件来显示每个用户的评论.在itemtemplate中有一个用于显示每个用户的评论的评论文本框.现在,当我单击编辑命令按钮时,我希望该评论文本框将被启用以编辑评论文本并单击更新时,用户注释将被更新.因此,只有当我单击相应项目中的编辑"时,其他所有注释项才会保持可见,文本框将处于编辑模式,然后单击更新"时将被更新.

在以下代码中,我没有对edititemtemplate.please使用任何内容.

I am using a datalist control to show per user comments.there is a comment textbox for showing comment per user in itemtemplate.now when i will click the edit command button i want that comment textbox will be enabled to edit comment text and when update is clicked that user comment will be updated.so every other comment items will stay visible only when i click edit in corresponding item the textbox will be in edit mode and then will be updated when update clicked.

in the following codes i did not use anything for edititemtemplate.please help.

<asp:DataList ID="DataList1" DataKeyField="CommentId" CssClass="MSComItem" runat="server" OnCancelCommand="DataList1_CancelCommand" OnUpdateCommand="DataList1_UpdateCommand"   
  OnEditCommand="DataList1_EditCommand">
     <itemtemplate>	
    <div style=" margin-removed130px;">
    <asp:Label ID="test" runat="server" />   
    <asp:LinkButton ID="Edit" Text="Edit" CommandName="edit" runat="server" />
     <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
    </div>
    <div id="ViewMain">
    <div id="dd" style="float:left"><asp:Image ID="logog" runat="server" ImageUrl="~/desktopmodules/mscomments/images/default_user.png" />    </div>
    <div id="arrow" style="float:left"><asp:Image ID="Image1" runat="server" ImageUrl="~/desktopmodules/mscomments/images/comment_arrow.gif" />   </div>
    <div id="ss" style="float:left"><asp:TextBox ID="Comments" Enabled="false" CssClass="textbox" BorderColor="White" BorderWidth="1px" TextMode="MultiLine" runat="server" Text=''<%# Bind("Comment")%>'' ></div> 
</div>
    </itemtemplate><edititemtemplate></edititemtemplate>   

推荐答案

感谢mkgoud
实际上我在链接中使用相同的代码是正确的,但是很困惑
Thanks mkgoud
actually i was right with same codes in the link but was confused


在这里检查.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.edititemtemplate.aspx [ http://programming.top54u.com/post/Working-with- DataList-EditItemTemplate-in-ASP-Net.aspx [ ^ ]
Check here.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.edititemtemplate.aspx[^]

http://programming.top54u.com/post/Working-with-DataList-EditItemTemplate-in-ASP-Net.aspx[^]


这篇关于如何使用itemtemplate的项目文本框作为数据列表中的edititemtemplate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆