asp.net问题,请各位大哥帮帮忙啊,在线等!

liming1019 2008-12-31 03:51:55



这是一个单击进入的链接进入的程序,其中<asp:LinkButton ID="btTitle" CommandName="edit" runat="server">与datalist控件的OnEditCommand="lstContent_EditCommand" 对应,
也就是点击链接执行lstContent_EditCommand事件,现在我想改为双击表格的行执行lstContent_EditCommand事件,该怎么做啊,帮帮忙啊。

<asp:DataList ID="lstContent" runat="server" CssClass="directoryLists" CellPadding="0"
CellSpacing="0" OnItemDataBound="lstContent_ItemDataBound" DataKeyField="FileID"
OnEditCommand="lstContent_EditCommand" Style="border-collapse: collapse;">
<HeaderTemplate>
<table class="Head" cellspacing="0" cellpadding="0" >
<tr>
<td class="Td1">
<asp:Label ID="Label1" runat="server">主题</asp:Label></td>
<td class="Td2">
<asp:Label ID="Label6" runat="server">类别</asp:Label></td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table class="Detail" cellspacing="0" cellpadding="0">
<tr class="trColor">
<td class="Td1">
<asp:LinkButton ID="btTitle" CommandName="edit" runat="server">
<asp:Label ID="lblTitle" runat="server" ></asp:Label>
</asp:LinkButton>
</td>
<td class="Td2">
<asp:Label ID="lblFileDB" runat="server"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>


...全文
194 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
liming1019 2008-12-31
  • 打赏
  • 举报
回复
还有什么办法吗。
zerostyle 2008-12-31
  • 打赏
  • 举报
回复
可以把DataList 的事件干掉,用其他方法来做
wanghao3616 2008-12-31
  • 打赏
  • 举报
回复
要变通 不要死实现
DNN-2017 2008-12-31
  • 打赏
  • 举报
回复
EditCommand事件是单击datalist的“edit”时激发的,如果要双击激发,不知道用JavaScript能不能在客户端屏蔽点单击事件,而当双击时再吃饭干事件。即使能做也会很费劲,你看不到.net的客户端的脚本代码,所以不好做。
zerostyle 2008-12-31
  • 打赏
  • 举报
回复
<asp:DataList ID="lstContent" runat="server" CssClass="directoryLists" CellPadding="0"
CellSpacing="0" OnItemDataBound="lstContent_ItemDataBound" DataKeyField="FileID"
OnEditCommand="lstContent_EditCommand" Style="border-collapse: collapse;">
<HeaderTemplate>
<table class="Head" cellspacing="0" cellpadding="0" >
<tr>
<td class="Td1">
<asp:Label ID="Label1" runat="server">主题 </asp:Label> </td>
<td class="Td2">
<asp:Label ID="Label6" runat="server">类别 </asp:Label> </td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table id="tab" runat="server" class="Detail" cellspacing="0" cellpadding="0">
<tr class="trColor">
<td class="Td1">
<asp:LinkButton ID="btTitle" CommandName="edit" runat="server">
<asp:Label ID="lblTitle" runat="server" > </asp:Label>
</asp:LinkButton>
</td>
<td class="Td2">
<asp:Label ID="lblFileDB" runat="server"> </asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>

后台:lstContent_ItemDataBound事件
中得到表格并且加一个属性
Table tab = (Table)e.Item.FindControl("tab");
tab.Attributes.Add("ondblclick","dosomething")
dosomething函数为JS函数,必须包含一个整型参数:行号
用js来设置当前行的控件状态,不用JS来控制状态还可以用下面的方法

还有一个变态的方法就是,放一个linkbutton,和一个hidden类型的input,隐藏使用
,当点击一行时,使用将hidden类型的input值设置为当前行的索引,然后调用linkbutton的后台事件读取这个input的值,然后就可以使用空参数来调用
lstContent_EditCommand(null,null)
lianglei9810 2008-12-31
  • 打赏
  • 举报
回复
写个 div 宽 高都100% 然后写上CommandName="edit"
试试
DNN-2017 2008-12-31
  • 打赏
  • 举报
回复
双击事件用JavaScript能捕捉到
lsj_zrp 2008-12-31
  • 打赏
  • 举报
回复
如果执行的是客户端的js还比较容易,但是如果是执行服务器的代码的话,比较困难
帮你顶一下
阿彪兄 2008-12-31
  • 打赏
  • 举报
回复
up
xycit 2008-12-31
  • 打赏
  • 举报
回复
up!

62,269

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧