linkbutton in a listview with a CommandArgument

3.8k Views Asked by At

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

1

There are 1 best solutions below

0
On

You 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