[2005] Wanting server side event for button in FormView
When I click on the button inside the formview, I get the default event for the FormView and not the button. Maybe there's no hope for this route.
Another option would be to put the button outside of the formview, but I also need access to one of the data fields from the FormView's binding to give the button custom text. How could one do this? using Eval("FieldName"), returns blank so that tells me that it's out of scope
Re: [2005] Wanting server side event for button in FormView
Give the button a CommandName/CommandArgument and you can then 'detect' it from the FormView's event.
Re: [2005] Wanting server side event for button in FormView
Can you give an example?
or Is there a way to bind the text of a button to an item from an objectdatasource?
Re: [2005] Wanting server side event for button in FormView
In your formview's template:
Code:
<asp:Button ID="btnDie" runat="server" CommandName="DIE" Text="DIE!!!" />
In the formview's ItemCommand event
Code:
Dim cmd as string
cmd = e.CommandName
If cmd = "DIE" Then
Die()
End If