如何在Repeater控件中使用ItemCommad [英] How to use ItemCommad in Repeater Control
本文介绍了如何在Repeater控件中使用ItemCommad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,所有
如何在转发器控制中将命令值获取到服务器端
我的代码:
Hi, All
How to get command value to server side in repeater control
My Code:
<ItemTemplate>
<asp:Panel ID="pnl_tr" runat="server">
<tr id="gh" align="center" style="removed: pointer" önclick="Select('<%# Eval("UserIdN")%>');">
<td><asp:CheckBox ID="chbxHT" runat="server"/></td>
<td><asp:Label ID="lblEmpCode" runat="server" Text='<%#Eval("UserIdN")%>'></asp:Label></td>
<td><asp:Label ID="Label1" runat="server" Text='<%#Eval("EmpCodeC")%>'></asp:Label></td>
<td><asp:Label ID="Label2" runat="server" Text='<%#Eval("empnamec")%>'></asp:Label></td>
<td><asp:Label ID="Label3" runat="server" Text='<%#Eval("deptcodec")%>'></asp:Label></td>
<td><asp:Label ID="Label5" runat="server" Text='<%#Eval("seccodec")%>'></asp:Label></td>
<td><asp:Label ID="Label6" runat="server" Text='<%#Eval("Dojd")%>'></asp:Label></td>
<td><asp:Label ID="Label7" runat="server" Text='<%#Eval("NricWPNoC")%>'></asp:Label></td>
<td><asp:Label ID="Label10" runat="server" Text='<%#Eval("ShiftGroupCodeC")%>'></asp:Label></td>
<td><asp:Label ID="Label11" runat="server" Text='<%#Eval("LocationC")%>'></asp:Label></td>
<td><asp:Label ID="Label12" runat="server" Text='<%#Eval("TerminateDateD")%>'></asp:Label></td>
<td><asp:Label ID="Label13" runat="server" Text='<%#Eval("Gender")%>'></asp:Label></td>
<td><asp:Label ID="Label14" runat="server" Text='<%#Eval("DOB")%>'></asp:Label></td>
<td><asp:Label ID="Label15" runat="server" Text='<%#Eval("Privilege")%>'></asp:Label></td>
<td><asp:Label ID="Label17" runat="server" Text='<%#Eval("Enabled")%>'></asp:Label></td>
<td><asp:Label ID="Label18" runat="server" Text='<%#Eval("CardNumber")%>'></asp:Label></td>
<asp:HiddenField ID="HiddenField1" runat="server" />
</tr>
</asp:Panel>
</ItemTemplate>
当我尝试使用此itemcommand时,不会触发...
When i try to use this itemcommand not fire...
推荐答案
我在中继器控件中看不到任何可以触发项目命令事件的按钮.
无论如何,请参考以下链接或有关ItemCommand事件的更多信息
ItemCommand事件-MSDN [ ^ ]
中继器项目命令问题 [
Hi,
I do not see any type of button inside your repeater control which can fire item command event.
Anyway refer below links or more on ItemCommand event
ItemCommand Event - MSDN[^]
Repeater Item Command Problem[^]
hope it helps.
在您的aspx
中
in your aspx
<asp:repeater id="Repeater1" runat="server" onitemcommand="Repeater1_ItemCommand">
<itemtemplate>
<asp:button id="btnDetails" runat="server" text="Details" cssclass="aspxcontrolbuttons" commandname="Details" commandargument="<%# Eval("SomeValue") %>"></asp:button>
</itemtemplate>
</asp:repeater>
在您的.cs中
in your .cs
public void Repeater1_ItemCommand(Object Sender, RepeaterCommandEventArgs e)
{
// check if the command name is close (if it's the button)
if (e.CommandName == "Details")
{
string ID = (string)e.CommandArgument;
//do something
}
}
这篇关于如何在Repeater控件中使用ItemCommad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文