C# linkbutton question object does not contain a definition for CommandArgument

  • Thread starter Thread starter needin4mation
  • Start date Start date
N

needin4mation

I have some VB.NET code that I am trying to convert. I'm not sure what
to do here and was hoping you could help.

Sub PagerButtonClick(sender As Object, e As EventArgs)
'used by external paging UI
Dim arg As String = sender.CommandArgument

is the code from:

http://www.4guysfromrolla.com/webtech/082901-1.2.shtml

I have tried this code in c# (converted as best I could) but I cannot
get the sender.CommandArgument to work.

It's just a button that calls a function on the server side. This
signature:

object sender, System.EventArgs e

does not have an CommandArgument.

I tried a cast like:

(System.Web.UI.WebControls.DataGridCommandEventArgs) sender, but it has
no effect.

I don't know what to do. Thank you for any help. How can I access the
command argument of a button that is not in the datagrid?
 
CommandArgument should come from EventArgs rather than from Object. Try

Dim arg As String = e.CommandArgument

HTH
 
I won't work as EventArgs or sender. There is no CommandArgument for
object or System.EventArgs. The VB Code allows it, but not the C# code.
 
Back
Top