Hi All,
Thanks in advance for any help. I know this has been covered elsewhere, but I can't seem to get it to work. The examples I have seen have been in C#, and I'm trying them in VB.
I'm creating a button for each row pulled from a database and assigning the commandargument to the the key of that row. I have two things I can't get to work.
One: When I create the button in the code behind file:
Dim lnkChange As New LinkButton()
lnkChange.Text = "Change"
lnkChange.ID = "ChangeDep"
lnkChange.CommandName = "ChangeDependent"
lnkChange.CommandArgument = rdrDependents.Item("dep_access_cntr".ToString
I don't get an OnClick or OnCommand option for lnkChange. I can't find anything that seems to serve the same purpose. I tried putting it and seeing what would happen (even with the wiggly blue line), but it didn't work...
This is some code I pulled from Microsoft's help:
<asp:Button id="Button1"
Text="Sort Ascending"
CommandName="Sort"
CommandArgument="Ascending"
OnCommand="CommandBtn_Click"
runat="server"/>
but I don't get that OnCommand option in the code behind.
Two: Even if I could get the button to know what to do when it was clicked, I'm having these problems: I wrote a sub procedure that's supposed to run when the button is clicked:
Private Sub ChangeDependent(ByVal sender As Object, ByVal e As EventArgs)
Session("DepCntr" = e
Server.Transfer("ChDependent.aspx"
End Sub
This shows up without problem in the code behind, but the example I found from Microsoft says:
Sub CommandBtn_Click(sender As Object, e As CommandEventArgs)
' Insert code to sort in ascending order here.
Message.Text = "You clicked the " & e.CommandName & _
" - " & e.CommandArgument & " button."
End Sub
So they're referring to e.CommandArgument, but when I do this, I get the wiggly blue line under the code and it says:
'CommandArgument is not a member of 'System.EventArgs''.
I tried adding Handles lnkChange after the function head line (like VS does when it creates the function), but it gives me the wiggly blue line once again.
Ok, well I hope this is clear!
Thanks a bunch!
Kimberly
Thanks in advance for any help. I know this has been covered elsewhere, but I can't seem to get it to work. The examples I have seen have been in C#, and I'm trying them in VB.
I'm creating a button for each row pulled from a database and assigning the commandargument to the the key of that row. I have two things I can't get to work.
One: When I create the button in the code behind file:
Dim lnkChange As New LinkButton()
lnkChange.Text = "Change"
lnkChange.ID = "ChangeDep"
lnkChange.CommandName = "ChangeDependent"
lnkChange.CommandArgument = rdrDependents.Item("dep_access_cntr".ToString
I don't get an OnClick or OnCommand option for lnkChange. I can't find anything that seems to serve the same purpose. I tried putting it and seeing what would happen (even with the wiggly blue line), but it didn't work...
This is some code I pulled from Microsoft's help:
<asp:Button id="Button1"
Text="Sort Ascending"
CommandName="Sort"
CommandArgument="Ascending"
OnCommand="CommandBtn_Click"
runat="server"/>
but I don't get that OnCommand option in the code behind.
Two: Even if I could get the button to know what to do when it was clicked, I'm having these problems: I wrote a sub procedure that's supposed to run when the button is clicked:
Private Sub ChangeDependent(ByVal sender As Object, ByVal e As EventArgs)
Session("DepCntr" = e
Server.Transfer("ChDependent.aspx"
End Sub
This shows up without problem in the code behind, but the example I found from Microsoft says:
Sub CommandBtn_Click(sender As Object, e As CommandEventArgs)
' Insert code to sort in ascending order here.
Message.Text = "You clicked the " & e.CommandName & _
" - " & e.CommandArgument & " button."
End Sub
So they're referring to e.CommandArgument, but when I do this, I get the wiggly blue line under the code and it says:
'CommandArgument is not a member of 'System.EventArgs''.
I tried adding Handles lnkChange after the function head line (like VS does when it creates the function), but it gives me the wiggly blue line once again.
Ok, well I hope this is clear!
Thanks a bunch!
Kimberly