Results 1 to 4 of 4

Thread: [2005] Wanting server side event for button in FormView

  1. #1

    Thread Starter
    Hyperactive Member wordracr's Avatar
    Join Date
    Aug 2001
    Posts
    281

    [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

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  3. #3

    Thread Starter
    Hyperactive Member wordracr's Avatar
    Join Date
    Aug 2001
    Posts
    281

    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?

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width