How to fire an event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniela Roman

    #1

    How to fire an event

    Hello,

    I try to fire an event under a button click event and maybe anybody can give
    a clue please.

    I have let's say a WEB grid with PageIndexChange d event:

    private void DataGrid1_PageI ndexChanged(obj ect source,
    System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)

    {

    // Set CurrentPageInde x to the page the user clicked.

    DataGrid1.Curre ntPageIndex = e.NewPageIndex;


    // Rebind the data.

    DataGrid1.DataB ind();

    }



    Under a button click event:

    private void btnUpdtCmd_Clic k(object sender, System.EventArg s e)

    {

    }



    I want to fire the grid's event but I don't know how to call the event and
    provide the parameter list for it:

    (object source, System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)



    Thank you,

    Daniela


  • Dave Sexton

    #2
    Re: How to fire an event

    Hi Daniela,
    I want to fire the grid's event but I don't know how to call the event and
    provide the parameter list for it:
    There are many events on the DataGrid control. You just have to perform an
    action that will cause the grid to raise the desired event. It's not common
    to raise Control events externally; Controls raise their own events
    internally.

    Are you trying to get the PageIndexChange d event to be raised from your button
    click event handler?

    If so, change the CurrentPageInde x property and the event should be raised by
    the DataGrid.

    --
    Dave Sexton

    "Daniela Roman" <danielaroman@r ogers.comwrote in message
    news:OOLr774AHH A.4592@TK2MSFTN GP03.phx.gbl...
    Hello,
    >
    I try to fire an event under a button click event and maybe anybody can give
    a clue please.
    >
    I have let's say a WEB grid with PageIndexChange d event:
    >
    private void DataGrid1_PageI ndexChanged(obj ect source,
    System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
    >
    {
    >
    // Set CurrentPageInde x to the page the user clicked.
    >
    DataGrid1.Curre ntPageIndex = e.NewPageIndex;
    >
    >
    // Rebind the data.
    >
    DataGrid1.DataB ind();
    >
    }
    >
    >
    >
    Under a button click event:
    >
    private void btnUpdtCmd_Clic k(object sender, System.EventArg s e)
    >
    {
    >
    }
    >
    >
    >
    I want to fire the grid's event but I don't know how to call the event and
    provide the parameter list for it:
    >
    (object source, System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
    >
    >
    >
    Thank you,
    >
    Daniela
    >
    >

    Comment

    • Daniela Roman

      #3
      Re: How to fire an event

      Thanks. In fact I use a 3-rd party WEB grid control and for some reason it
      does not fire the UpdateRowBatch event when I change the values of the grid
      thru code. I need to raise that event thru other means.
      The sample I provided is not the best example.

      Is there another way of firing an event externally?


      "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
      news:eHN$8z5AHH A.4992@TK2MSFTN GP03.phx.gbl...
      Hi Daniela,
      >
      >I want to fire the grid's event but I don't know how to call the event
      >and provide the parameter list for it:
      >
      There are many events on the DataGrid control. You just have to perform
      an action that will cause the grid to raise the desired event. It's not
      common to raise Control events externally; Controls raise their own events
      internally.
      >
      Are you trying to get the PageIndexChange d event to be raised from your
      button click event handler?
      >
      If so, change the CurrentPageInde x property and the event should be raised
      by the DataGrid.
      >
      --
      Dave Sexton
      >
      "Daniela Roman" <danielaroman@r ogers.comwrote in message
      news:OOLr774AHH A.4592@TK2MSFTN GP03.phx.gbl...
      >Hello,
      >>
      >I try to fire an event under a button click event and maybe anybody can
      >give a clue please.
      >>
      >I have let's say a WEB grid with PageIndexChange d event:
      >>
      >private void DataGrid1_PageI ndexChanged(obj ect source,
      >System.Web.UI. WebControls.Dat aGridPageChange dEventArgs e)
      >>
      >{
      >>
      >// Set CurrentPageInde x to the page the user clicked.
      >>
      >DataGrid1.Curr entPageIndex = e.NewPageIndex;
      >>
      >>
      >// Rebind the data.
      >>
      >DataGrid1.Data Bind();
      >>
      >}
      >>
      >>
      >>
      >Under a button click event:
      >>
      >private void btnUpdtCmd_Clic k(object sender, System.EventArg s e)
      >>
      >{
      >>
      >}
      >>
      >>
      >>
      >I want to fire the grid's event but I don't know how to call the event
      >and provide the parameter list for it:
      >>
      >(object source, System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
      >>
      >>
      >>
      >Thank you,
      >>
      >Daniela
      >>
      >>
      >
      >

      Comment

      • Dave Sexton

        #4
        Re: How to fire an event

        Hi Daniela,

        I've seen some Controls that provide Raise[Event] methods, but usually not for
        every event anyway. And I don't really like the idea either :)

        I would contact the manufacturer or find a forum dedicated to that control
        where people might have had similar issues. It definitely sounds like a bug.

        --
        Dave Sexton

        "Daniela Roman" <danielaroman@r ogers.comwrote in message
        news:emku445AHH A.4568@TK2MSFTN GP04.phx.gbl...
        Thanks. In fact I use a 3-rd party WEB grid control and for some reason it
        does not fire the UpdateRowBatch event when I change the values of the grid
        thru code. I need to raise that event thru other means.
        The sample I provided is not the best example.
        >
        Is there another way of firing an event externally?
        >
        >
        "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
        news:eHN$8z5AHH A.4992@TK2MSFTN GP03.phx.gbl...
        >Hi Daniela,
        >>
        >>I want to fire the grid's event but I don't know how to call the event and
        >>provide the parameter list for it:
        >>
        >There are many events on the DataGrid control. You just have to perform an
        >action that will cause the grid to raise the desired event. It's not
        >common to raise Control events externally; Controls raise their own events
        >internally.
        >>
        >Are you trying to get the PageIndexChange d event to be raised from your
        >button click event handler?
        >>
        >If so, change the CurrentPageInde x property and the event should be raised
        >by the DataGrid.
        >>
        >--
        >Dave Sexton
        >>
        >"Daniela Roman" <danielaroman@r ogers.comwrote in message
        >news:OOLr774AH HA.4592@TK2MSFT NGP03.phx.gbl.. .
        >>Hello,
        >>>
        >>I try to fire an event under a button click event and maybe anybody can
        >>give a clue please.
        >>>
        >>I have let's say a WEB grid with PageIndexChange d event:
        >>>
        >>private void DataGrid1_PageI ndexChanged(obj ect source,
        >>System.Web.UI .WebControls.Da taGridPageChang edEventArgs e)
        >>>
        >>{
        >>>
        >>// Set CurrentPageInde x to the page the user clicked.
        >>>
        >>DataGrid1.Cur rentPageIndex = e.NewPageIndex;
        >>>
        >>>
        >>// Rebind the data.
        >>>
        >>DataGrid1.Dat aBind();
        >>>
        >>}
        >>>
        >>>
        >>>
        >>Under a button click event:
        >>>
        >>private void btnUpdtCmd_Clic k(object sender, System.EventArg s e)
        >>>
        >>{
        >>>
        >>}
        >>>
        >>>
        >>>
        >>I want to fire the grid's event but I don't know how to call the event and
        >>provide the parameter list for it:
        >>>
        >>(object source, System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
        >>>
        >>>
        >>>
        >>Thank you,
        >>>
        >>Daniela
        >>>
        >>>
        >>
        >>
        >
        >

        Comment

        • Dave Sexton

          #5
          Re: How to fire an event

          Hi Daniela,

          .... and in the mean time, you can possibly solve your problem by placing the
          code from the event handler that isn't being called (which you could call
          directly anyway) into another method as such:

          void gd_UpdateRowBat ch(object sender, EventArgs e)
          {
          CommonMethod();
          }

          void btn_Click(objec t sender, EventArgs e)
          {
          CommonMethod();
          }

          void CommonMethod()
          {
          // TODO: something in common
          }

          If the grid does things that require the event to actually be raised, you
          might be able to emulate the effect yourself in the CommonMethod.

          GL

          --
          Dave Sexton

          "Daniela Roman" <danielaroman@r ogers.comwrote in message
          news:emku445AHH A.4568@TK2MSFTN GP04.phx.gbl...
          Thanks. In fact I use a 3-rd party WEB grid control and for some reason it
          does not fire the UpdateRowBatch event when I change the values of the grid
          thru code. I need to raise that event thru other means.
          The sample I provided is not the best example.
          >
          Is there another way of firing an event externally?
          >
          >
          "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
          news:eHN$8z5AHH A.4992@TK2MSFTN GP03.phx.gbl...
          >Hi Daniela,
          >>
          >>I want to fire the grid's event but I don't know how to call the event and
          >>provide the parameter list for it:
          >>
          >There are many events on the DataGrid control. You just have to perform an
          >action that will cause the grid to raise the desired event. It's not
          >common to raise Control events externally; Controls raise their own events
          >internally.
          >>
          >Are you trying to get the PageIndexChange d event to be raised from your
          >button click event handler?
          >>
          >If so, change the CurrentPageInde x property and the event should be raised
          >by the DataGrid.
          >>
          >--
          >Dave Sexton
          >>
          >"Daniela Roman" <danielaroman@r ogers.comwrote in message
          >news:OOLr774AH HA.4592@TK2MSFT NGP03.phx.gbl.. .
          >>Hello,
          >>>
          >>I try to fire an event under a button click event and maybe anybody can
          >>give a clue please.
          >>>
          >>I have let's say a WEB grid with PageIndexChange d event:
          >>>
          >>private void DataGrid1_PageI ndexChanged(obj ect source,
          >>System.Web.UI .WebControls.Da taGridPageChang edEventArgs e)
          >>>
          >>{
          >>>
          >>// Set CurrentPageInde x to the page the user clicked.
          >>>
          >>DataGrid1.Cur rentPageIndex = e.NewPageIndex;
          >>>
          >>>
          >>// Rebind the data.
          >>>
          >>DataGrid1.Dat aBind();
          >>>
          >>}
          >>>
          >>>
          >>>
          >>Under a button click event:
          >>>
          >>private void btnUpdtCmd_Clic k(object sender, System.EventArg s e)
          >>>
          >>{
          >>>
          >>}
          >>>
          >>>
          >>>
          >>I want to fire the grid's event but I don't know how to call the event and
          >>provide the parameter list for it:
          >>>
          >>(object source, System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
          >>>
          >>>
          >>>
          >>Thank you,
          >>>
          >>Daniela
          >>>
          >>>
          >>
          >>
          >
          >

          Comment

          • Daniela Roman

            #6
            Re: How to fire an event

            Thank you. I will give it a try tomorrow. I have to see how I can deal with
            the parameters.


            "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
            news:uFOxT$5AHH A.4060@TK2MSFTN GP03.phx.gbl...
            Hi Daniela,
            >
            ... and in the mean time, you can possibly solve your problem by placing
            the code from the event handler that isn't being called (which you could
            call directly anyway) into another method as such:
            >
            void gd_UpdateRowBat ch(object sender, EventArgs e)
            {
            CommonMethod();
            }
            >
            void btn_Click(objec t sender, EventArgs e)
            {
            CommonMethod();
            }
            >
            void CommonMethod()
            {
            // TODO: something in common
            }
            >
            If the grid does things that require the event to actually be raised, you
            might be able to emulate the effect yourself in the CommonMethod.
            >
            GL
            >
            --
            Dave Sexton
            >
            "Daniela Roman" <danielaroman@r ogers.comwrote in message
            news:emku445AHH A.4568@TK2MSFTN GP04.phx.gbl...
            >Thanks. In fact I use a 3-rd party WEB grid control and for some reason
            >it does not fire the UpdateRowBatch event when I change the values of the
            >grid thru code. I need to raise that event thru other means.
            >The sample I provided is not the best example.
            >>
            >Is there another way of firing an event externally?
            >>
            >>
            >"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
            >news:eHN$8z5AH HA.4992@TK2MSFT NGP03.phx.gbl.. .
            >>Hi Daniela,
            >>>
            >>>I want to fire the grid's event but I don't know how to call the event
            >>>and provide the parameter list for it:
            >>>
            >>There are many events on the DataGrid control. You just have to perform
            >>an action that will cause the grid to raise the desired event. It's not
            >>common to raise Control events externally; Controls raise their own
            >>events internally.
            >>>
            >>Are you trying to get the PageIndexChange d event to be raised from your
            >>button click event handler?
            >>>
            >>If so, change the CurrentPageInde x property and the event should be
            >>raised by the DataGrid.
            >>>
            >>--
            >>Dave Sexton
            >>>
            >>"Daniela Roman" <danielaroman@r ogers.comwrote in message
            >>news:OOLr774A HHA.4592@TK2MSF TNGP03.phx.gbl. ..
            >>>Hello,
            >>>>
            >>>I try to fire an event under a button click event and maybe anybody can
            >>>give a clue please.
            >>>>
            >>>I have let's say a WEB grid with PageIndexChange d event:
            >>>>
            >>>private void DataGrid1_PageI ndexChanged(obj ect source,
            >>>System.Web.U I.WebControls.D ataGridPageChan gedEventArgs e)
            >>>>
            >>>{
            >>>>
            >>>// Set CurrentPageInde x to the page the user clicked.
            >>>>
            >>>DataGrid1.Cu rrentPageIndex = e.NewPageIndex;
            >>>>
            >>>>
            >>>// Rebind the data.
            >>>>
            >>>DataGrid1.Da taBind();
            >>>>
            >>>}
            >>>>
            >>>>
            >>>>
            >>>Under a button click event:
            >>>>
            >>>private void btnUpdtCmd_Clic k(object sender, System.EventArg s e)
            >>>>
            >>>{
            >>>>
            >>>}
            >>>>
            >>>>
            >>>>
            >>>I want to fire the grid's event but I don't know how to call the event
            >>>and provide the parameter list for it:
            >>>>
            >>>(object source, System.Web.UI.W ebControls.Data GridPageChanged EventArgs
            >>>e)
            >>>>
            >>>>
            >>>>
            >>>Thank you,
            >>>>
            >>>Daniela
            >>>>
            >>>>
            >>>
            >>>
            >>
            >>
            >
            >

            Comment

            • Cor Ligthert [MVP]

              #7
              Re: How to fire an event

              Daniela,

              Are you sure you want to fire the event, and not just what the event does.

              TheMethod(null, null)'if you want to use a sender object it is up to you

              Cor

              "Daniela Roman" <danielaroman@r ogers.comschree f in bericht
              news:OOLr774AHH A.4592@TK2MSFTN GP03.phx.gbl...
              Hello,
              >
              I try to fire an event under a button click event and maybe anybody can
              give a clue please.
              >
              I have let's say a WEB grid with PageIndexChange d event:
              >
              private void DataGrid1_PageI ndexChanged(obj ect source,
              System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
              >
              {
              >
              // Set CurrentPageInde x to the page the user clicked.
              >
              DataGrid1.Curre ntPageIndex = e.NewPageIndex;
              >
              >
              // Rebind the data.
              >
              DataGrid1.DataB ind();
              >
              }
              >
              >
              >
              Under a button click event:
              >
              private void btnUpdtCmd_Clic k(object sender, System.EventArg s e)
              >
              {
              >
              }
              >
              >
              >
              I want to fire the grid's event but I don't know how to call the event and
              provide the parameter list for it:
              >
              (object source, System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
              >
              >
              >
              Thank you,
              >
              Daniela
              >
              >

              Comment

              • Daniela Roman

                #8
                Re: How to fire an event

                It seems that changing values by code, which is done on client side does not
                triger an event. I would need to force a postback. How can it be done?

                Of course I can use the code under the event for the button click event, but
                the other one would loop thru all the rows automatically.


                "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                news:uFOxT$5AHH A.4060@TK2MSFTN GP03.phx.gbl...
                Hi Daniela,
                >
                ... and in the mean time, you can possibly solve your problem by placing
                the code from the event handler that isn't being called (which you could
                call directly anyway) into another method as such:
                >
                void gd_UpdateRowBat ch(object sender, EventArgs e)
                {
                CommonMethod();
                }
                >
                void btn_Click(objec t sender, EventArgs e)
                {
                CommonMethod();
                }
                >
                void CommonMethod()
                {
                // TODO: something in common
                }
                >
                If the grid does things that require the event to actually be raised, you
                might be able to emulate the effect yourself in the CommonMethod.
                >
                GL
                >
                --
                Dave Sexton
                >
                "Daniela Roman" <danielaroman@r ogers.comwrote in message
                news:emku445AHH A.4568@TK2MSFTN GP04.phx.gbl...
                >Thanks. In fact I use a 3-rd party WEB grid control and for some reason
                >it does not fire the UpdateRowBatch event when I change the values of the
                >grid thru code. I need to raise that event thru other means.
                >The sample I provided is not the best example.
                >>
                >Is there another way of firing an event externally?
                >>
                >>
                >"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                >news:eHN$8z5AH HA.4992@TK2MSFT NGP03.phx.gbl.. .
                >>Hi Daniela,
                >>>
                >>>I want to fire the grid's event but I don't know how to call the event
                >>>and provide the parameter list for it:
                >>>
                >>There are many events on the DataGrid control. You just have to perform
                >>an action that will cause the grid to raise the desired event. It's not
                >>common to raise Control events externally; Controls raise their own
                >>events internally.
                >>>
                >>Are you trying to get the PageIndexChange d event to be raised from your
                >>button click event handler?
                >>>
                >>If so, change the CurrentPageInde x property and the event should be
                >>raised by the DataGrid.
                >>>
                >>--
                >>Dave Sexton
                >>>
                >>"Daniela Roman" <danielaroman@r ogers.comwrote in message
                >>news:OOLr774A HHA.4592@TK2MSF TNGP03.phx.gbl. ..
                >>>Hello,
                >>>>
                >>>I try to fire an event under a button click event and maybe anybody can
                >>>give a clue please.
                >>>>
                >>>I have let's say a WEB grid with PageIndexChange d event:
                >>>>
                >>>private void DataGrid1_PageI ndexChanged(obj ect source,
                >>>System.Web.U I.WebControls.D ataGridPageChan gedEventArgs e)
                >>>>
                >>>{
                >>>>
                >>>// Set CurrentPageInde x to the page the user clicked.
                >>>>
                >>>DataGrid1.Cu rrentPageIndex = e.NewPageIndex;
                >>>>
                >>>>
                >>>// Rebind the data.
                >>>>
                >>>DataGrid1.Da taBind();
                >>>>
                >>>}
                >>>>
                >>>>
                >>>>
                >>>Under a button click event:
                >>>>
                >>>private void btnUpdtCmd_Clic k(object sender, System.EventArg s e)
                >>>>
                >>>{
                >>>>
                >>>}
                >>>>
                >>>>
                >>>>
                >>>I want to fire the grid's event but I don't know how to call the event
                >>>and provide the parameter list for it:
                >>>>
                >>>(object source, System.Web.UI.W ebControls.Data GridPageChanged EventArgs
                >>>e)
                >>>>
                >>>>
                >>>>
                >>>Thank you,
                >>>>
                >>>Daniela
                >>>>
                >>>>
                >>>
                >>>
                >>
                >>
                >
                >

                Comment

                • Dave Sexton

                  #9
                  Re: How to fire an event

                  Hi Daniela,
                  It seems that changing values by code, which is done on client side does not
                  triger an event. I would need to force a postback. How can it be done?
                  You should have mentioned that the "code" you spoke of was actually script,
                  running on the client. I never would have thought that manipulating the grid
                  in script would cause a server event to be raised.

                  You can force a post back by dynamically adding the ASP.NET javascript
                  postback method call to your own client script. This can be done by calling
                  the GetPostBackEven tReference method (Page class in 1.* and Page.ClientScri pt
                  in 2.0) on the server to insert the callback into your own script:

                  <script type="text/javascript">
                  function doingThings()
                  {
                  // do some things in javascript

                  // post back to raise the button's click event
                  <%= ClientScript.Ge tPostBackEventR eference(gridCo ntrol, string.Empty) %>
                  }
                  </script>

                  The problem here is that I have no idea whether the grid will raise the
                  UpdateRowBatch event on a post back. What action in particular raises the
                  UpdateRowBatch event? What argument needs to be supplied, if any? You might
                  want to read the grid's documentation and figure out what that event is
                  intended for before trying to raise it yourself.

                  The alternative to posting back for the grid control is to post back for your
                  button control (change "gridContro l" to "myButton" in the javascript above,
                  for example) and perform the actions in code, on the server, as I suggested in
                  my previous response.

                  If you don't want to use a button then you can postback to the Page (change
                  "gridContro l" to "this" or "Page" in the javascript above) and implement
                  IPostBackEventH andler.
                  Of course I can use the code under the event for the button click event, but
                  the other one would loop thru all the rows automatically.
                  If you can do so then it will be much easier (and safer) to iterate all of the
                  rows yourself when the button is pressed than it would be to try to rig the
                  event to be raised unnaturally.

                  Please realize that if what you are trying to accomplish has absolutely
                  nothing to do with the grid's UpdateRowBatch event then you shouldn't be using
                  the event at all.

                  --
                  Dave Sexton

                  "Daniela Roman" <danielaroman@r ogers.comwrote in message
                  news:e73uiaHBHH A.4428@TK2MSFTN GP04.phx.gbl...
                  It seems that changing values by code, which is done on client side does not
                  triger an event. I would need to force a postback. How can it be done?
                  >
                  Of course I can use the code under the event for the button click event, but
                  the other one would loop thru all the rows automatically.
                  >
                  >
                  "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                  news:uFOxT$5AHH A.4060@TK2MSFTN GP03.phx.gbl...
                  >Hi Daniela,
                  >>
                  >... and in the mean time, you can possibly solve your problem by placing
                  >the code from the event handler that isn't being called (which you could
                  >call directly anyway) into another method as such:
                  >>
                  >void gd_UpdateRowBat ch(object sender, EventArgs e)
                  >{
                  > CommonMethod();
                  >}
                  >>
                  >void btn_Click(objec t sender, EventArgs e)
                  >{
                  > CommonMethod();
                  >}
                  >>
                  >void CommonMethod()
                  >{
                  > // TODO: something in common
                  >}
                  >>
                  >If the grid does things that require the event to actually be raised, you
                  >might be able to emulate the effect yourself in the CommonMethod.
                  >>
                  >GL
                  >>
                  >--
                  >Dave Sexton
                  >>
                  >"Daniela Roman" <danielaroman@r ogers.comwrote in message
                  >news:emku445AH HA.4568@TK2MSFT NGP04.phx.gbl.. .
                  >>Thanks. In fact I use a 3-rd party WEB grid control and for some reason it
                  >>does not fire the UpdateRowBatch event when I change the values of the
                  >>grid thru code. I need to raise that event thru other means.
                  >>The sample I provided is not the best example.
                  >>>
                  >>Is there another way of firing an event externally?
                  >>>
                  >>>
                  >>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                  >>news:eHN$8z5A HHA.4992@TK2MSF TNGP03.phx.gbl. ..
                  >>>Hi Daniela,
                  >>>>
                  >>>>I want to fire the grid's event but I don't know how to call the event
                  >>>>and provide the parameter list for it:
                  >>>>
                  >>>There are many events on the DataGrid control. You just have to perform
                  >>>an action that will cause the grid to raise the desired event. It's not
                  >>>common to raise Control events externally; Controls raise their own
                  >>>events internally.
                  >>>>
                  >>>Are you trying to get the PageIndexChange d event to be raised from your
                  >>>button click event handler?
                  >>>>
                  >>>If so, change the CurrentPageInde x property and the event should be
                  >>>raised by the DataGrid.
                  >>>>
                  >>>--
                  >>>Dave Sexton
                  >>>>
                  >>>"Daniela Roman" <danielaroman@r ogers.comwrote in message
                  >>>news:OOLr774 AHHA.4592@TK2MS FTNGP03.phx.gbl ...
                  >>>>Hello,
                  >>>>>
                  >>>>I try to fire an event under a button click event and maybe anybody can
                  >>>>give a clue please.
                  >>>>>
                  >>>>I have let's say a WEB grid with PageIndexChange d event:
                  >>>>>
                  >>>>private void DataGrid1_PageI ndexChanged(obj ect source,
                  >>>>System.Web. UI.WebControls. DataGridPageCha ngedEventArgs e)
                  >>>>>
                  >>>>{
                  >>>>>
                  >>>>// Set CurrentPageInde x to the page the user clicked.
                  >>>>>
                  >>>>DataGrid1.C urrentPageIndex = e.NewPageIndex;
                  >>>>>
                  >>>>>
                  >>>>// Rebind the data.
                  >>>>>
                  >>>>DataGrid1.D ataBind();
                  >>>>>
                  >>>>}
                  >>>>>
                  >>>>>
                  >>>>>
                  >>>>Under a button click event:
                  >>>>>
                  >>>>private void btnUpdtCmd_Clic k(object sender, System.EventArg s e)
                  >>>>>
                  >>>>{
                  >>>>>
                  >>>>}
                  >>>>>
                  >>>>>
                  >>>>>
                  >>>>I want to fire the grid's event but I don't know how to call the event
                  >>>>and provide the parameter list for it:
                  >>>>>
                  >>>>(object source, System.Web.UI.W ebControls.Data GridPageChanged EventArgs
                  >>>>e)
                  >>>>>
                  >>>>>
                  >>>>>
                  >>>>Thank you,
                  >>>>>
                  >>>>Daniela
                  >>>>>
                  >>>>>
                  >>>>
                  >>>>
                  >>>
                  >>>
                  >>
                  >>
                  >
                  >

                  Comment

                  • Daniela Roman

                    #10
                    Re: How to fire an event

                    Hi Dave,
                    There is no script code, I have a check box column and I loop thru the rows,
                    marking them as checked, all done under a button click event in C#.
                    Is it client side or server side?
                    In my oppinion it is server side.

                    "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                    news:upQsLBIBHH A.4568@TK2MSFTN GP04.phx.gbl...
                    Hi Daniela,
                    >
                    >It seems that changing values by code, which is done on client side does
                    >not triger an event. I would need to force a postback. How can it be
                    >done?
                    >
                    You should have mentioned that the "code" you spoke of was actually
                    script, running on the client. I never would have thought that
                    manipulating the grid in script would cause a server event to be raised.
                    >
                    You can force a post back by dynamically adding the ASP.NET javascript
                    postback method call to your own client script. This can be done by
                    calling the GetPostBackEven tReference method (Page class in 1.* and
                    Page.ClientScri pt in 2.0) on the server to insert the callback into your
                    own script:
                    >
                    <script type="text/javascript">
                    function doingThings()
                    {
                    // do some things in javascript
                    >
                    // post back to raise the button's click event
                    <%= ClientScript.Ge tPostBackEventR eference(gridCo ntrol, string.Empty)
                    %>
                    }
                    </script>
                    >
                    The problem here is that I have no idea whether the grid will raise the
                    UpdateRowBatch event on a post back. What action in particular raises the
                    UpdateRowBatch event? What argument needs to be supplied, if any? You
                    might want to read the grid's documentation and figure out what that event
                    is intended for before trying to raise it yourself.
                    >
                    The alternative to posting back for the grid control is to post back for
                    your button control (change "gridContro l" to "myButton" in the javascript
                    above, for example) and perform the actions in code, on the server, as I
                    suggested in my previous response.
                    >
                    If you don't want to use a button then you can postback to the Page
                    (change "gridContro l" to "this" or "Page" in the javascript above) and
                    implement IPostBackEventH andler.
                    >
                    >Of course I can use the code under the event for the button click event,
                    >but the other one would loop thru all the rows automatically.
                    >
                    If you can do so then it will be much easier (and safer) to iterate all of
                    the rows yourself when the button is pressed than it would be to try to
                    rig the event to be raised unnaturally.
                    >
                    Please realize that if what you are trying to accomplish has absolutely
                    nothing to do with the grid's UpdateRowBatch event then you shouldn't be
                    using the event at all.
                    >
                    --
                    Dave Sexton
                    >
                    "Daniela Roman" <danielaroman@r ogers.comwrote in message
                    news:e73uiaHBHH A.4428@TK2MSFTN GP04.phx.gbl...
                    >It seems that changing values by code, which is done on client side does
                    >not triger an event. I would need to force a postback. How can it be
                    >done?
                    >>
                    >Of course I can use the code under the event for the button click event,
                    >but the other one would loop thru all the rows automatically.
                    >>
                    >>
                    >"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                    >news:uFOxT$5AH HA.4060@TK2MSFT NGP03.phx.gbl.. .
                    >>Hi Daniela,
                    >>>
                    >>... and in the mean time, you can possibly solve your problem by placing
                    >>the code from the event handler that isn't being called (which you could
                    >>call directly anyway) into another method as such:
                    >>>
                    >>void gd_UpdateRowBat ch(object sender, EventArgs e)
                    >>{
                    >> CommonMethod();
                    >>}
                    >>>
                    >>void btn_Click(objec t sender, EventArgs e)
                    >>{
                    >> CommonMethod();
                    >>}
                    >>>
                    >>void CommonMethod()
                    >>{
                    >> // TODO: something in common
                    >>}
                    >>>
                    >>If the grid does things that require the event to actually be raised,
                    >>you might be able to emulate the effect yourself in the CommonMethod.
                    >>>
                    >>GL
                    >>>
                    >>--
                    >>Dave Sexton
                    >>>
                    >>"Daniela Roman" <danielaroman@r ogers.comwrote in message
                    >>news:emku445A HHA.4568@TK2MSF TNGP04.phx.gbl. ..
                    >>>Thanks. In fact I use a 3-rd party WEB grid control and for some reason
                    >>>it does not fire the UpdateRowBatch event when I change the values of
                    >>>the grid thru code. I need to raise that event thru other means.
                    >>>The sample I provided is not the best example.
                    >>>>
                    >>>Is there another way of firing an event externally?
                    >>>>
                    >>>>
                    >>>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                    >>>news:eHN$8z5 AHHA.4992@TK2MS FTNGP03.phx.gbl ...
                    >>>>Hi Daniela,
                    >>>>>
                    >>>>>I want to fire the grid's event but I don't know how to call the
                    >>>>>event and provide the parameter list for it:
                    >>>>>
                    >>>>There are many events on the DataGrid control. You just have to
                    >>>>perform an action that will cause the grid to raise the desired event.
                    >>>>It's not common to raise Control events externally; Controls raise
                    >>>>their own events internally.
                    >>>>>
                    >>>>Are you trying to get the PageIndexChange d event to be raised from
                    >>>>your button click event handler?
                    >>>>>
                    >>>>If so, change the CurrentPageInde x property and the event should be
                    >>>>raised by the DataGrid.
                    >>>>>
                    >>>>--
                    >>>>Dave Sexton
                    >>>>>
                    >>>>"Daniela Roman" <danielaroman@r ogers.comwrote in message
                    >>>>news:OOLr77 4AHHA.4592@TK2M SFTNGP03.phx.gb l...
                    >>>>>Hello,
                    >>>>>>
                    >>>>>I try to fire an event under a button click event and maybe anybody
                    >>>>>can give a clue please.
                    >>>>>>
                    >>>>>I have let's say a WEB grid with PageIndexChange d event:
                    >>>>>>
                    >>>>>private void DataGrid1_PageI ndexChanged(obj ect source,
                    >>>>>System.Web .UI.WebControls .DataGridPageCh angedEventArgs e)
                    >>>>>>
                    >>>>>{
                    >>>>>>
                    >>>>>// Set CurrentPageInde x to the page the user clicked.
                    >>>>>>
                    >>>>>DataGrid1. CurrentPageInde x = e.NewPageIndex;
                    >>>>>>
                    >>>>>>
                    >>>>>// Rebind the data.
                    >>>>>>
                    >>>>>DataGrid1. DataBind();
                    >>>>>>
                    >>>>>}
                    >>>>>>
                    >>>>>>
                    >>>>>>
                    >>>>>Under a button click event:
                    >>>>>>
                    >>>>>private void btnUpdtCmd_Clic k(object sender, System.EventArg s e)
                    >>>>>>
                    >>>>>{
                    >>>>>>
                    >>>>>}
                    >>>>>>
                    >>>>>>
                    >>>>>>
                    >>>>>I want to fire the grid's event but I don't know how to call the
                    >>>>>event and provide the parameter list for it:
                    >>>>>>
                    >>>>>(object source,
                    >>>>>System.Web .UI.WebControls .DataGridPageCh angedEventArgs e)
                    >>>>>>
                    >>>>>>
                    >>>>>>
                    >>>>>Thank you,
                    >>>>>>
                    >>>>>Daniela
                    >>>>>>
                    >>>>>>
                    >>>>>
                    >>>>>
                    >>>>
                    >>>>
                    >>>
                    >>>
                    >>
                    >>
                    >
                    >

                    Comment

                    • Dave Sexton

                      #11
                      Re: How to fire an event

                      Hi Daniela,

                      If the code is C# then it's running on the server :)

                      The button click event is being raised upon a post-back to the server. Since
                      you're apparently iterating the rows in the click event handler already I
                      don't see why you desire the UpdateRowBatch event to be raised. It seems like
                      an arbitrary choice.

                      What exactly do you need from this event?

                      --
                      Dave Sexton

                      "Daniela Roman" <danielaroman@r ogers.comwrote in message
                      news:e1ckaAUBHH A.4864@TK2MSFTN GP04.phx.gbl...
                      Hi Dave,
                      There is no script code, I have a check box column and I loop thru the rows,
                      marking them as checked, all done under a button click event in C#.
                      Is it client side or server side?
                      In my oppinion it is server side.
                      >
                      "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                      news:upQsLBIBHH A.4568@TK2MSFTN GP04.phx.gbl...
                      >Hi Daniela,
                      >>
                      >>It seems that changing values by code, which is done on client side does
                      >>not triger an event. I would need to force a postback. How can it be done?
                      >>
                      >You should have mentioned that the "code" you spoke of was actually script,
                      >running on the client. I never would have thought that manipulating the
                      >grid in script would cause a server event to be raised.
                      >>
                      >You can force a post back by dynamically adding the ASP.NET javascript
                      >postback method call to your own client script. This can be done by
                      >calling the GetPostBackEven tReference method (Page class in 1.* and
                      >Page.ClientScr ipt in 2.0) on the server to insert the callback into your
                      >own script:
                      >>
                      ><script type="text/javascript">
                      >function doingThings()
                      >{
                      > // do some things in javascript
                      >>
                      > // post back to raise the button's click event
                      > <%= ClientScript.Ge tPostBackEventR eference(gridCo ntrol, string.Empty) %>
                      >}
                      ></script>
                      >>
                      >The problem here is that I have no idea whether the grid will raise the
                      >UpdateRowBat ch event on a post back. What action in particular raises the
                      >UpdateRowBat ch event? What argument needs to be supplied, if any? You
                      >might want to read the grid's documentation and figure out what that event
                      >is intended for before trying to raise it yourself.
                      >>
                      >The alternative to posting back for the grid control is to post back for
                      >your button control (change "gridContro l" to "myButton" in the javascript
                      >above, for example) and perform the actions in code, on the server, as I
                      >suggested in my previous response.
                      >>
                      >If you don't want to use a button then you can postback to the Page (change
                      >"gridControl " to "this" or "Page" in the javascript above) and implement
                      >IPostBackEvent Handler.
                      >>
                      >>Of course I can use the code under the event for the button click event,
                      >>but the other one would loop thru all the rows automatically.
                      >>
                      >If you can do so then it will be much easier (and safer) to iterate all of
                      >the rows yourself when the button is pressed than it would be to try to rig
                      >the event to be raised unnaturally.
                      >>
                      >Please realize that if what you are trying to accomplish has absolutely
                      >nothing to do with the grid's UpdateRowBatch event then you shouldn't be
                      >using the event at all.
                      >>
                      >--
                      >Dave Sexton
                      >>
                      >"Daniela Roman" <danielaroman@r ogers.comwrote in message
                      >news:e73uiaHBH HA.4428@TK2MSFT NGP04.phx.gbl.. .
                      >>It seems that changing values by code, which is done on client side does
                      >>not triger an event. I would need to force a postback. How can it be done?
                      >>>
                      >>Of course I can use the code under the event for the button click event,
                      >>but the other one would loop thru all the rows automatically.
                      >>>
                      >>>
                      >>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                      >>news:uFOxT$5A HHA.4060@TK2MSF TNGP03.phx.gbl. ..
                      >>>Hi Daniela,
                      >>>>
                      >>>... and in the mean time, you can possibly solve your problem by placing
                      >>>the code from the event handler that isn't being called (which you could
                      >>>call directly anyway) into another method as such:
                      >>>>
                      >>>void gd_UpdateRowBat ch(object sender, EventArgs e)
                      >>>{
                      >>> CommonMethod();
                      >>>}
                      >>>>
                      >>>void btn_Click(objec t sender, EventArgs e)
                      >>>{
                      >>> CommonMethod();
                      >>>}
                      >>>>
                      >>>void CommonMethod()
                      >>>{
                      >>> // TODO: something in common
                      >>>}
                      >>>>
                      >>>If the grid does things that require the event to actually be raised, you
                      >>>might be able to emulate the effect yourself in the CommonMethod.
                      >>>>
                      >>>GL
                      >>>>
                      >>>--
                      >>>Dave Sexton
                      >>>>
                      >>>"Daniela Roman" <danielaroman@r ogers.comwrote in message
                      >>>news:emku445 AHHA.4568@TK2MS FTNGP04.phx.gbl ...
                      >>>>Thanks. In fact I use a 3-rd party WEB grid control and for some reason
                      >>>>it does not fire the UpdateRowBatch event when I change the values of
                      >>>>the grid thru code. I need to raise that event thru other means.
                      >>>>The sample I provided is not the best example.
                      >>>>>
                      >>>>Is there another way of firing an event externally?
                      >>>>>
                      >>>>>
                      >>>>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                      >>>>news:eHN$8z 5AHHA.4992@TK2M SFTNGP03.phx.gb l...
                      >>>>>Hi Daniela,
                      >>>>>>
                      >>>>>>I want to fire the grid's event but I don't know how to call the event
                      >>>>>>and provide the parameter list for it:
                      >>>>>>
                      >>>>>There are many events on the DataGrid control. You just have to
                      >>>>>perform an action that will cause the grid to raise the desired event.
                      >>>>>It's not common to raise Control events externally; Controls raise
                      >>>>>their own events internally.
                      >>>>>>
                      >>>>>Are you trying to get the PageIndexChange d event to be raised from your
                      >>>>>button click event handler?
                      >>>>>>
                      >>>>>If so, change the CurrentPageInde x property and the event should be
                      >>>>>raised by the DataGrid.
                      >>>>>>
                      >>>>>--
                      >>>>>Dave Sexton
                      >>>>>>
                      >>>>>"Daniela Roman" <danielaroman@r ogers.comwrote in message
                      >>>>>news:OOLr7 74AHHA.4592@TK2 MSFTNGP03.phx.g bl...
                      >>>>>>Hello,
                      >>>>>>>
                      >>>>>>I try to fire an event under a button click event and maybe anybody
                      >>>>>>can give a clue please.
                      >>>>>>>
                      >>>>>>I have let's say a WEB grid with PageIndexChange d event:
                      >>>>>>>
                      >>>>>>private void DataGrid1_PageI ndexChanged(obj ect source,
                      >>>>>>System.We b.UI.WebControl s.DataGridPageC hangedEventArgs e)
                      >>>>>>>
                      >>>>>>{
                      >>>>>>>
                      >>>>>>// Set CurrentPageInde x to the page the user clicked.
                      >>>>>>>
                      >>>>>>DataGrid1 .CurrentPageInd ex = e.NewPageIndex;
                      >>>>>>>
                      >>>>>>>
                      >>>>>>// Rebind the data.
                      >>>>>>>
                      >>>>>>DataGrid1 .DataBind();
                      >>>>>>>
                      >>>>>>}
                      >>>>>>>
                      >>>>>>>
                      >>>>>>>
                      >>>>>>Under a button click event:
                      >>>>>>>
                      >>>>>>private void btnUpdtCmd_Clic k(object sender, System.EventArg s e)
                      >>>>>>>
                      >>>>>>{
                      >>>>>>>
                      >>>>>>}
                      >>>>>>>
                      >>>>>>>
                      >>>>>>>
                      >>>>>>I want to fire the grid's event but I don't know how to call the event
                      >>>>>>and provide the parameter list for it:
                      >>>>>>>
                      >>>>>>(object source, System.Web.UI.W ebControls.Data GridPageChanged EventArgs
                      >>>>>>e)
                      >>>>>>>
                      >>>>>>>
                      >>>>>>>
                      >>>>>>Thank you,
                      >>>>>>>
                      >>>>>>Daniela
                      >>>>>>>
                      >>>>>>>
                      >>>>>>
                      >>>>>>
                      >>>>>
                      >>>>>
                      >>>>
                      >>>>
                      >>>
                      >>>
                      >>
                      >>
                      >
                      >

                      Comment

                      • Daniela Roman

                        #12
                        Re: How to fire an event

                        Hi Dave,

                        It's my bad I did not provide enough details on the matter.
                        The ideea is: I have an Infragistic datagrid control, one of the columns is
                        a check box. One of the buttons is Check All, which will check all the check
                        boxes in the grid. Then the option is to either cancel the process and
                        uncheck them or go ahead and save the changes. For this there are 2 other
                        buttons, Save and Cancel. Under save I need to trigger the UpdateRowBatch
                        event. A collegue suggested that it does not trigger because the code is
                        doing the changes on the client side, which sincerely did not make much
                        sense to me.


                        "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                        news:uZmbQOVBHH A.3396@TK2MSFTN GP02.phx.gbl...
                        Hi Daniela,
                        >
                        If the code is C# then it's running on the server :)
                        >
                        The button click event is being raised upon a post-back to the server.
                        Since you're apparently iterating the rows in the click event handler
                        already I don't see why you desire the UpdateRowBatch event to be raised.
                        It seems like an arbitrary choice.
                        >
                        What exactly do you need from this event?
                        >
                        --
                        Dave Sexton
                        >
                        "Daniela Roman" <danielaroman@r ogers.comwrote in message
                        news:e1ckaAUBHH A.4864@TK2MSFTN GP04.phx.gbl...
                        >Hi Dave,
                        >There is no script code, I have a check box column and I loop thru the
                        >rows, marking them as checked, all done under a button click event in C#.
                        >Is it client side or server side?
                        >In my oppinion it is server side.
                        >>
                        >"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                        >news:upQsLBIBH HA.4568@TK2MSFT NGP04.phx.gbl.. .
                        >>Hi Daniela,
                        >>>
                        >>>It seems that changing values by code, which is done on client side
                        >>>does not triger an event. I would need to force a postback. How can it
                        >>>be done?
                        >>>
                        >>You should have mentioned that the "code" you spoke of was actually
                        >>script, running on the client. I never would have thought that
                        >>manipulatin g the grid in script would cause a server event to be raised.
                        >>>
                        >>You can force a post back by dynamically adding the ASP.NET javascript
                        >>postback method call to your own client script. This can be done by
                        >>calling the GetPostBackEven tReference method (Page class in 1.* and
                        >>Page.ClientSc ript in 2.0) on the server to insert the callback into your
                        >>own script:
                        >>>
                        >><script type="text/javascript">
                        >>function doingThings()
                        >>{
                        >> // do some things in javascript
                        >>>
                        >> // post back to raise the button's click event
                        >> <%= ClientScript.Ge tPostBackEventR eference(gridCo ntrol, string.Empty)
                        >>%>
                        >>}
                        >></script>
                        >>>
                        >>The problem here is that I have no idea whether the grid will raise the
                        >>UpdateRowBatc h event on a post back. What action in particular raises
                        >>the UpdateRowBatch event? What argument needs to be supplied, if any?
                        >>You might want to read the grid's documentation and figure out what that
                        >>event is intended for before trying to raise it yourself.
                        >>>
                        >>The alternative to posting back for the grid control is to post back for
                        >>your button control (change "gridContro l" to "myButton" in the
                        >>javascript above, for example) and perform the actions in code, on the
                        >>server, as I suggested in my previous response.
                        >>>
                        >>If you don't want to use a button then you can postback to the Page
                        >>(change "gridContro l" to "this" or "Page" in the javascript above) and
                        >>implement IPostBackEventH andler.
                        >>>
                        >>>Of course I can use the code under the event for the button click
                        >>>event, but the other one would loop thru all the rows automatically.
                        >>>
                        >>If you can do so then it will be much easier (and safer) to iterate all
                        >>of the rows yourself when the button is pressed than it would be to try
                        >>to rig the event to be raised unnaturally.
                        >>>
                        >>Please realize that if what you are trying to accomplish has absolutely
                        >>nothing to do with the grid's UpdateRowBatch event then you shouldn't be
                        >>using the event at all.
                        >>>
                        >>--
                        >>Dave Sexton
                        >>>
                        >>"Daniela Roman" <danielaroman@r ogers.comwrote in message
                        >>news:e73uiaHB HHA.4428@TK2MSF TNGP04.phx.gbl. ..
                        >>>It seems that changing values by code, which is done on client side
                        >>>does not triger an event. I would need to force a postback. How can it
                        >>>be done?
                        >>>>
                        >>>Of course I can use the code under the event for the button click
                        >>>event, but the other one would loop thru all the rows automatically.
                        >>>>
                        >>>>
                        >>>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                        >>>news:uFOxT$5 AHHA.4060@TK2MS FTNGP03.phx.gbl ...
                        >>>>Hi Daniela,
                        >>>>>
                        >>>>... and in the mean time, you can possibly solve your problem by
                        >>>>placing the code from the event handler that isn't being called (which
                        >>>>you could call directly anyway) into another method as such:
                        >>>>>
                        >>>>void gd_UpdateRowBat ch(object sender, EventArgs e)
                        >>>>{
                        >>>> CommonMethod();
                        >>>>}
                        >>>>>
                        >>>>void btn_Click(objec t sender, EventArgs e)
                        >>>>{
                        >>>> CommonMethod();
                        >>>>}
                        >>>>>
                        >>>>void CommonMethod()
                        >>>>{
                        >>>> // TODO: something in common
                        >>>>}
                        >>>>>
                        >>>>If the grid does things that require the event to actually be raised,
                        >>>>you might be able to emulate the effect yourself in the CommonMethod.
                        >>>>>
                        >>>>GL
                        >>>>>
                        >>>>--
                        >>>>Dave Sexton
                        >>>>>
                        >>>>"Daniela Roman" <danielaroman@r ogers.comwrote in message
                        >>>>news:emku44 5AHHA.4568@TK2M SFTNGP04.phx.gb l...
                        >>>>>Thanks. In fact I use a 3-rd party WEB grid control and for some
                        >>>>>reason it does not fire the UpdateRowBatch event when I change the
                        >>>>>values of the grid thru code. I need to raise that event thru other
                        >>>>>means.
                        >>>>>The sample I provided is not the best example.
                        >>>>>>
                        >>>>>Is there another way of firing an event externally?
                        >>>>>>
                        >>>>>>
                        >>>>>"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                        >>>>>news:eHN$8 z5AHHA.4992@TK2 MSFTNGP03.phx.g bl...
                        >>>>>>Hi Daniela,
                        >>>>>>>
                        >>>>>>>I want to fire the grid's event but I don't know how to call the
                        >>>>>>>event and provide the parameter list for it:
                        >>>>>>>
                        >>>>>>There are many events on the DataGrid control. You just have to
                        >>>>>>perform an action that will cause the grid to raise the desired
                        >>>>>>event. It's not common to raise Control events externally; Controls
                        >>>>>>raise their own events internally.
                        >>>>>>>
                        >>>>>>Are you trying to get the PageIndexChange d event to be raised from
                        >>>>>>your button click event handler?
                        >>>>>>>
                        >>>>>>If so, change the CurrentPageInde x property and the event should be
                        >>>>>>raised by the DataGrid.
                        >>>>>>>
                        >>>>>>--
                        >>>>>>Dave Sexton
                        >>>>>>>
                        >>>>>>"Daniel a Roman" <danielaroman@r ogers.comwrote in message
                        >>>>>>news:OOLr 774AHHA.4592@TK 2MSFTNGP03.phx. gbl...
                        >>>>>>>Hello,
                        >>>>>>>>
                        >>>>>>>I try to fire an event under a button click event and maybe anybody
                        >>>>>>>can give a clue please.
                        >>>>>>>>
                        >>>>>>>I have let's say a WEB grid with PageIndexChange d event:
                        >>>>>>>>
                        >>>>>>>privat e void DataGrid1_PageI ndexChanged(obj ect source,
                        >>>>>>>System.W eb.UI.WebContro ls.DataGridPage ChangedEventArg s e)
                        >>>>>>>>
                        >>>>>>>{
                        >>>>>>>>
                        >>>>>>>// Set CurrentPageInde x to the page the user clicked.
                        >>>>>>>>
                        >>>>>>>DataGrid 1.CurrentPageIn dex = e.NewPageIndex;
                        >>>>>>>>
                        >>>>>>>>
                        >>>>>>>// Rebind the data.
                        >>>>>>>>
                        >>>>>>>DataGrid 1.DataBind();
                        >>>>>>>>
                        >>>>>>>}
                        >>>>>>>>
                        >>>>>>>>
                        >>>>>>>>
                        >>>>>>>Under a button click event:
                        >>>>>>>>
                        >>>>>>>privat e void btnUpdtCmd_Clic k(object sender, System.EventArg s e)
                        >>>>>>>>
                        >>>>>>>{
                        >>>>>>>>
                        >>>>>>>}
                        >>>>>>>>
                        >>>>>>>>
                        >>>>>>>>
                        >>>>>>>I want to fire the grid's event but I don't know how to call the
                        >>>>>>>event and provide the parameter list for it:
                        >>>>>>>>
                        >>>>>>>(objec t source,
                        >>>>>>>System.W eb.UI.WebContro ls.DataGridPage ChangedEventArg s e)
                        >>>>>>>>
                        >>>>>>>>
                        >>>>>>>>
                        >>>>>>>Thank you,
                        >>>>>>>>
                        >>>>>>>Daniel a
                        >>>>>>>>
                        >>>>>>>>
                        >>>>>>>
                        >>>>>>>
                        >>>>>>
                        >>>>>>
                        >>>>>
                        >>>>>
                        >>>>
                        >>>>
                        >>>
                        >>>
                        >>
                        >>
                        >
                        >

                        Comment

                        • Dave Sexton

                          #13
                          Re: How to fire an event

                          Hi Daniela,
                          It's my bad I did not provide enough details on the matter.
                          The ideea is: I have an Infragistic datagrid control, one of the columns is
                          a check box. One of the buttons is Check All, which will check all the check
                          boxes in the grid. Then the option is to either cancel the process and
                          uncheck them or go ahead and save the changes. For this there are 2 other
                          buttons, Save and Cancel. Under save I need to trigger the UpdateRowBatch
                          event.
                          Thank you for the background information, but it's still not clear why you
                          want to raise the UpdateRowBatch event. What do you expect it to do?

                          You might want to check out some Infragistics forums and documentation
                          pertaining to the UpdateRowBatch event if you're not sure why it's not being
                          raised when you expect it to be.

                          Realize though that forcing the event to be raised might not cause the grid to
                          perform the expected actions that are associated with the event. In other
                          words, events notify subscribers of an action - raising the event yourself (if
                          you could) would not cause the action to occur. Instead, if you perform the
                          appropriate action on the grid then the event will be raised. This is
                          normally how controls behave, although I have to admit that I'm not familiar
                          with the Infragistics grid and it may behave differently.

                          So you should try to figure out:

                          1. how to perform the appropriate action on the grid to raise the event
                          2. whether the action required to raise the event is even necessary in the
                          first place
                          A collegue suggested that it does not trigger because the code is doing the
                          changes on the client side, which sincerely did not make much sense to me.
                          What changes?

                          When the Save button is clicked, if your C# code in the Save button click
                          event handler is executed, then there is either a post-back or AJAX at work
                          here. In either case, the Save button's click event is certainly being raised
                          on the server.

                          It's possible that there are changes occurring on the client-side before,
                          after and even during (if AJAX is used) the server click event. Although, I
                          suspect that there is a full post-back occurring when the Save button is
                          clicked (meaning AJAX isn't being used).

                          --
                          Dave Sexton


                          Comment

                          • Daniela Roman

                            #14
                            Re: How to fire an event

                            Unfortunately the Infragistics documentation is very poor, that means it
                            doesn's say anything about what triggers the event and when.
                            Why I used the Update RowBatch? I wanted to keep the same structure as the
                            other pages have (I came into project half way) and this event handles the
                            looping automaically, the programmer only provides the action for one row
                            (updating the record), the event will do then the process for each row in
                            the grid. I did not understand why when I click the check boxes with the
                            mouse and then click Save button it triggers the UpdateRowBatch, but when I
                            change the value of the check boxes thru C# code it doesn't.


                            "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                            news:OLLI$ciBHH A.140@TK2MSFTNG P03.phx.gbl...
                            Hi Daniela,
                            >
                            >It's my bad I did not provide enough details on the matter.
                            >The ideea is: I have an Infragistic datagrid control, one of the columns
                            >is a check box. One of the buttons is Check All, which will check all the
                            >check boxes in the grid. Then the option is to either cancel the process
                            >and uncheck them or go ahead and save the changes. For this there are 2
                            >other buttons, Save and Cancel. Under save I need to trigger the
                            >UpdateRowBat ch event.
                            >
                            Thank you for the background information, but it's still not clear why you
                            want to raise the UpdateRowBatch event. What do you expect it to do?
                            >
                            You might want to check out some Infragistics forums and documentation
                            pertaining to the UpdateRowBatch event if you're not sure why it's not
                            being raised when you expect it to be.
                            >
                            Realize though that forcing the event to be raised might not cause the
                            grid to perform the expected actions that are associated with the event.
                            In other words, events notify subscribers of an action - raising the event
                            yourself (if you could) would not cause the action to occur. Instead, if
                            you perform the appropriate action on the grid then the event will be
                            raised. This is normally how controls behave, although I have to admit
                            that I'm not familiar with the Infragistics grid and it may behave
                            differently.
                            >
                            So you should try to figure out:
                            >
                            1. how to perform the appropriate action on the grid to raise the event
                            2. whether the action required to raise the event is even necessary in the
                            first place
                            >
                            >A collegue suggested that it does not trigger because the code is doing
                            >the changes on the client side, which sincerely did not make much sense
                            >to me.
                            >
                            What changes?
                            >
                            When the Save button is clicked, if your C# code in the Save button click
                            event handler is executed, then there is either a post-back or AJAX at
                            work here. In either case, the Save button's click event is certainly
                            being raised on the server.
                            >
                            It's possible that there are changes occurring on the client-side before,
                            after and even during (if AJAX is used) the server click event. Although,
                            I suspect that there is a full post-back occurring when the Save button is
                            clicked (meaning AJAX isn't being used).
                            >
                            --
                            Dave Sexton
                            >
                            >

                            Comment

                            • Dave Sexton

                              #15
                              Re: How to fire an event

                              Hi Daniela,

                              Well it could be a bug in the grid, but it's probably just misuse.

                              I assume that the "other pages' structure" performs different actions than
                              your page and that's why you are observing different behavior. If you are not
                              doing the same thing on your page then you might need to handle the save
                              operation differently as well - without use of the event.

                              This is an Infragistics-related problem. It has to do with performing the
                              appropriate action to cause a particular event to be raised. Again, you need
                              to figure out what actions cause the event to be raised and perform them.

                              As an alternative, you can iterate the rows in your own code.

                              If the documentation is poor then I suggest looking for Infragistics-related
                              forums.

                              GL

                              --
                              Dave Sexton

                              "Daniela Roman" <danielaroman@r ogers.comwrote in message
                              news:OhZxUwpBHH A.4024@TK2MSFTN GP04.phx.gbl...
                              Unfortunately the Infragistics documentation is very poor, that means it
                              doesn's say anything about what triggers the event and when.
                              Why I used the Update RowBatch? I wanted to keep the same structure as the
                              other pages have (I came into project half way) and this event handles the
                              looping automaically, the programmer only provides the action for one row
                              (updating the record), the event will do then the process for each row in
                              the grid. I did not understand why when I click the check boxes with the
                              mouse and then click Save button it triggers the UpdateRowBatch, but when I
                              change the value of the check boxes thru C# code it doesn't.
                              >
                              >
                              "Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
                              news:OLLI$ciBHH A.140@TK2MSFTNG P03.phx.gbl...
                              >Hi Daniela,
                              >>
                              >>It's my bad I did not provide enough details on the matter.
                              >>The ideea is: I have an Infragistic datagrid control, one of the columns
                              >>is a check box. One of the buttons is Check All, which will check all the
                              >>check boxes in the grid. Then the option is to either cancel the process
                              >>and uncheck them or go ahead and save the changes. For this there are 2
                              >>other buttons, Save and Cancel. Under save I need to trigger the
                              >>UpdateRowBatc h event.
                              >>
                              >Thank you for the background information, but it's still not clear why you
                              >want to raise the UpdateRowBatch event. What do you expect it to do?
                              >>
                              >You might want to check out some Infragistics forums and documentation
                              >pertaining to the UpdateRowBatch event if you're not sure why it's not
                              >being raised when you expect it to be.
                              >>
                              >Realize though that forcing the event to be raised might not cause the grid
                              >to perform the expected actions that are associated with the event. In
                              >other words, events notify subscribers of an action - raising the event
                              >yourself (if you could) would not cause the action to occur. Instead, if
                              >you perform the appropriate action on the grid then the event will be
                              >raised. This is normally how controls behave, although I have to admit
                              >that I'm not familiar with the Infragistics grid and it may behave
                              >differently.
                              >>
                              >So you should try to figure out:
                              >>
                              >1. how to perform the appropriate action on the grid to raise the event
                              >2. whether the action required to raise the event is even necessary in the
                              >first place
                              >>
                              >>A collegue suggested that it does not trigger because the code is doing
                              >>the changes on the client side, which sincerely did not make much sense to
                              >>me.
                              >>
                              >What changes?
                              >>
                              >When the Save button is clicked, if your C# code in the Save button click
                              >event handler is executed, then there is either a post-back or AJAX at work
                              >here. In either case, the Save button's click event is certainly being
                              >raised on the server.
                              >>
                              >It's possible that there are changes occurring on the client-side before,
                              >after and even during (if AJAX is used) the server click event. Although,
                              >I suspect that there is a full post-back occurring when the Save button is
                              >clicked (meaning AJAX isn't being used).
                              >>
                              >--
                              >Dave Sexton
                              >>
                              >>
                              >
                              >

                              Comment

                              Working...