带有 CommandArgument 的列表视图中的链接按钮
我正在使用 VS 2010、vb.net、.net 4。
我有一个列表视图,其中在 asp:tablecell 中包含一个 asp:linkbutton。问题是命令参数不是正确的值。
<asp:LinkButton ID="lbICS" runat="server" CommandName="cmdICS" CommandArgument='<%# eval("tblCalendarID")%>' Text='<%# eval("tblCalendarID").ToString %>'/>
当您查看它时,您会发现命令争论和文本绑定到相同的属性。我的文本属性读取为 386,但是当我单击 386 文本时,会触发 _ItemCommand 事件。当我执行 e.CommandArgument 时,该值是 46。我不明白我做错了什么。
Protected Sub lvCalendar_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles lvCalendar.ItemCommand If e.CommandName = "cmdICS" Then Dim mCalId As Integer = CInt(e.CommandArgument)
希望有人能帮忙
I'm using VS 2010, vb.net, .net 4.
I have a list view that holds a asp:linkbutton in an asp:tablecell. The problem is that the command argument is not the right value.
<asp:LinkButton ID="lbICS" runat="server" CommandName="cmdICS" CommandArgument='<%# eval("tblCalendarID")%>' Text='<%# eval("tblCalendarID").ToString %>'/>
when you look at it, you'll see that the command arguement and the text are bound to the same property. My text property reads 386, but when i click on the 386 text, the _ItemCommand event fires. when i do an e.CommandArgument, the value is 46. I don't understand what i'm doing wrong.
Protected Sub lvCalendar_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles lvCalendar.ItemCommand If e.CommandName = "cmdICS" Then Dim mCalId As Integer = CInt(e.CommandArgument)
hope someone can help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在获取 ListView 命令参数 ID,因为您正在尝试获取 ListView 项命令
lvCalendar_ItemCommand
中的命令参数,您必须右键单击
lbICS
按钮的链接,那么你就能够正确地论证。如果您查看此
ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs
您会注意到这是一个 ListView ArgumentYou are getting your ListView command Argument ID, as you are trying to get the command Argument in the ListView Item Command
lvCalendar_ItemCommand
You have to right Click the link of your
lbICS
button, then you will able to get right the argument.If you look at this
ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs
you will notice that this is a ListView Argument