By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,550 Members | 2,725 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,550 IT Pros & Developers. It's quick & easy.

How to fire an event

P: n/a
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 PageIndexChanged event:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e)

{

// Set CurrentPageIndex to the page the user clicked.

DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.

DataGrid1.DataBind();

}

Under a button click event:

private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args e)

Thank you,

Daniela
Nov 8 '06 #1
Share this Question
Share on Google+
19 Replies


P: n/a
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 PageIndexChanged event to be raised from your button
click event handler?

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

--
Dave Sexton

"Daniela Roman" <da**********@rogers.comwrote in message
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e)

{

// Set CurrentPageIndex to the page the user clicked.

DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.

DataGrid1.DataBind();

}

Under a button click event:

private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args e)

Thank you,

Daniela


Nov 9 '06 #2

P: n/a
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:eH**************@TK2MSFTNGP03.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 PageIndexChanged event to be raised from your
button click event handler?

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

--
Dave Sexton

"Daniela Roman" <da**********@rogers.comwrote in message
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEven tArgs e)

{

// Set CurrentPageIndex to the page the user clicked.

DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.

DataGrid1.DataBind();

}

Under a button click event:

private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args e)

Thank you,

Daniela



Nov 9 '06 #3

P: n/a
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" <da**********@rogers.comwrote in message
news:em**************@TK2MSFTNGP04.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:eH**************@TK2MSFTNGP03.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 PageIndexChanged event to be raised from your
button click event handler?

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

--
Dave Sexton

"Daniela Roman" <da**********@rogers.comwrote in message
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEve ntArgs e)

{

// Set CurrentPageIndex to the page the user clicked.

DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.

DataGrid1.DataBind();

}

Under a button click event:

private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args e)

Thank you,

Daniela




Nov 9 '06 #4

P: n/a
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_UpdateRowBatch(object sender, EventArgs e)
{
CommonMethod();
}

void btn_Click(object 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" <da**********@rogers.comwrote in message
news:em**************@TK2MSFTNGP04.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:eH**************@TK2MSFTNGP03.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 PageIndexChanged event to be raised from your
button click event handler?

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

--
Dave Sexton

"Daniela Roman" <da**********@rogers.comwrote in message
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEve ntArgs e)

{

// Set CurrentPageIndex to the page the user clicked.

DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.

DataGrid1.DataBind();

}

Under a button click event:

private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args e)

Thank you,

Daniela




Nov 9 '06 #5

P: n/a
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:uF**************@TK2MSFTNGP03.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_UpdateRowBatch(object sender, EventArgs e)
{
CommonMethod();
}

void btn_Click(object 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" <da**********@rogers.comwrote in message
news:em**************@TK2MSFTNGP04.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:eH**************@TK2MSFTNGP03.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 PageIndexChanged event to be raised from your
button click event handler?

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

--
Dave Sexton

"Daniela Roman" <da**********@rogers.comwrote in message
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEv entArgs e)

{

// Set CurrentPageIndex to the page the user clicked.

DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.

DataGrid1.DataBind();

}

Under a button click event:

private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args
e)

Thank you,

Daniela




Nov 9 '06 #6

P: n/a
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" <da**********@rogers.comschreef in bericht
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e)

{

// Set CurrentPageIndex to the page the user clicked.

DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.

DataGrid1.DataBind();

}

Under a button click event:

private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args e)

Thank you,

Daniela


Nov 9 '06 #7

P: n/a
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:uF**************@TK2MSFTNGP03.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_UpdateRowBatch(object sender, EventArgs e)
{
CommonMethod();
}

void btn_Click(object 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" <da**********@rogers.comwrote in message
news:em**************@TK2MSFTNGP04.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:eH**************@TK2MSFTNGP03.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 PageIndexChanged event to be raised from your
button click event handler?

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

--
Dave Sexton

"Daniela Roman" <da**********@rogers.comwrote in message
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEv entArgs e)

{

// Set CurrentPageIndex to the page the user clicked.

DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.

DataGrid1.DataBind();

}

Under a button click event:

private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args
e)

Thank you,

Daniela




Nov 10 '06 #8

P: n/a
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 GetPostBackEventReference method (Page class in 1.* and Page.ClientScript
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.GetPostBackEventReference(gridControl , 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 "gridControl" 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
IPostBackEventHandler.
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" <da**********@rogers.comwrote in message
news:e7**************@TK2MSFTNGP04.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:uF**************@TK2MSFTNGP03.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_UpdateRowBatch(object sender, EventArgs e)
{
CommonMethod();
}

void btn_Click(object 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" <da**********@rogers.comwrote in message
news:em**************@TK2MSFTNGP04.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:eH**************@TK2MSFTNGP03.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 PageIndexChanged event to be raised from your
button click event handler?

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

--
Dave Sexton

"Daniela Roman" <da**********@rogers.comwrote in message
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:
>
private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedE ventArgs e)
>
{
>
// Set CurrentPageIndex to the page the user clicked.
>
DataGrid1.CurrentPageIndex = e.NewPageIndex;
>
>
// Rebind the data.
>
DataGrid1.DataBind();
>
}
>
>
>
Under a button click event:
>
private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args
e)
>
>
>
Thank you,
>
Daniela
>
>




Nov 10 '06 #9

P: n/a
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:up**************@TK2MSFTNGP04.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 GetPostBackEventReference method (Page class in 1.* and
Page.ClientScript 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.GetPostBackEventReference(gridControl , 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 "gridControl" 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 IPostBackEventHandler.
>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" <da**********@rogers.comwrote in message
news:e7**************@TK2MSFTNGP04.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:uF**************@TK2MSFTNGP03.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_UpdateRowBatch(object sender, EventArgs e)
{
CommonMethod();
}

void btn_Click(object 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" <da**********@rogers.comwrote in message
news:em**************@TK2MSFTNGP04.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:eH**************@TK2MSFTNGP03.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 PageIndexChanged event to be raised from
your button click event handler?
>
If so, change the CurrentPageIndex property and the event should be
raised by the DataGrid.
>
--
Dave Sexton
>
"Daniela Roman" <da**********@rogers.comwrote in message
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:
>>
>private void DataGrid1_PageIndexChanged(object source,
>System.Web.UI.WebControls.DataGridPageChanged EventArgs e)
>>
>{
>>
>// Set CurrentPageIndex to the page the user clicked.
>>
>DataGrid1.CurrentPageIndex = e.NewPageIndex;
>>
>>
>// Rebind the data.
>>
>DataGrid1.DataBind();
>>
>}
>>
>>
>>
>Under a button click event:
>>
>private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChanged EventArgs e)
>>
>>
>>
>Thank you,
>>
>Daniela
>>
>>
>
>




Nov 11 '06 #10

P: n/a
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" <da**********@rogers.comwrote in message
news:e1**************@TK2MSFTNGP04.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:up**************@TK2MSFTNGP04.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 GetPostBackEventReference method (Page class in 1.* and
Page.ClientScript 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.GetPostBackEventReference(gridControl , 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 "gridControl" 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
IPostBackEventHandler.
>>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" <da**********@rogers.comwrote in message
news:e7**************@TK2MSFTNGP04.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:uF**************@TK2MSFTNGP03.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_UpdateRowBatch(object sender, EventArgs e)
{
CommonMethod();
}

void btn_Click(object 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" <da**********@rogers.comwrote in message
news:em**************@TK2MSFTNGP04.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:eH**************@TK2MSFTNGP03.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 PageIndexChanged event to be raised from your
>button click event handler?
>>
>If so, change the CurrentPageIndex property and the event should be
>raised by the DataGrid.
>>
>--
>Dave Sexton
>>
>"Daniela Roman" <da**********@rogers.comwrote in message
>news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:
>>>
>>private void DataGrid1_PageIndexChanged(object source,
>>System.Web.UI.WebControls.DataGridPageChange dEventArgs e)
>>>
>>{
>>>
>>// Set CurrentPageIndex to the page the user clicked.
>>>
>>DataGrid1.CurrentPageIndex = e.NewPageIndex;
>>>
>>>
>>// Rebind the data.
>>>
>>DataGrid1.DataBind();
>>>
>>}
>>>
>>>
>>>
>>Under a button click event:
>>>
>>private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args
>>e)
>>>
>>>
>>>
>>Thank you,
>>>
>>Daniela
>>>
>>>
>>
>>
>
>




Nov 11 '06 #11

P: n/a
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:uZ**************@TK2MSFTNGP02.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" <da**********@rogers.comwrote in message
news:e1**************@TK2MSFTNGP04.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:up**************@TK2MSFTNGP04.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 GetPostBackEventReference method (Page class in 1.* and
Page.ClientScript 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.GetPostBackEventReference(gridControl , 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 "gridControl" 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 IPostBackEventHandler.

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" <da**********@rogers.comwrote in message
news:e7**************@TK2MSFTNGP04.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:uF**************@TK2MSFTNGP03.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_UpdateRowBatch(object sender, EventArgs e)
{
CommonMethod();
}
>
void btn_Click(object 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" <da**********@rogers.comwrote in message
news:em**************@TK2MSFTNGP04.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:eH**************@TK2MSFTNGP03.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 PageIndexChanged event to be raised from
>>your button click event handler?
>>>
>>If so, change the CurrentPageIndex property and the event should be
>>raised by the DataGrid.
>>>
>>--
>>Dave Sexton
>>>
>>"Daniela Roman" <da**********@rogers.comwrote in message
>>news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:
>>>>
>>>private void DataGrid1_PageIndexChanged(object source,
>>>System.Web.UI.WebControls.DataGridPageChang edEventArgs e)
>>>>
>>>{
>>>>
>>>// Set CurrentPageIndex to the page the user clicked.
>>>>
>>>DataGrid1.CurrentPageIndex = e.NewPageIndex;
>>>>
>>>>
>>>// Rebind the data.
>>>>
>>>DataGrid1.DataBind();
>>>>
>>>}
>>>>
>>>>
>>>>
>>>Under a button click event:
>>>>
>>>private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChang edEventArgs e)
>>>>
>>>>
>>>>
>>>Thank you,
>>>>
>>>Daniela
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Nov 12 '06 #12

P: n/a
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
Nov 12 '06 #13

P: n/a
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:OL*************@TK2MSFTNGP03.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
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


Nov 12 '06 #14

P: n/a
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" <da**********@rogers.comwrote in message
news:Oh**************@TK2MSFTNGP04.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:OL*************@TK2MSFTNGP03.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
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



Nov 12 '06 #15

P: n/a
There are 2 scenarios:
- checking the boxes with the mouse
- checking them by code.
The same code for Save calls the event only when I click them with the
mouse. Looping through the rows with a for() doesn't do the expected
behaviour. What can I possibly do in the for() so that I misuse it?
The other page does the checking of the boxes in a javascript, that is
client side.

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
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" <da**********@rogers.comwrote in message
news:Oh**************@TK2MSFTNGP04.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:OL*************@TK2MSFTNGP03.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 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




Nov 12 '06 #16

P: n/a
Hi Daniela,

Well you might not be misusing the grid. It could be a bug.

I'm just assuming that the grid wasn't designed to do what you expect it to be
doing. To use the grid "correctly" you have to figure out what you "should"
be doing instead.

Because it's an Infragistics grid you'll probably find better support in a
forum dedicated to Infragistics, whether it's a bug or not.

--
Dave Sexton

"Daniela Roman" <da**********@rogers.comwrote in message
news:eQ**************@TK2MSFTNGP04.phx.gbl...
There are 2 scenarios:
- checking the boxes with the mouse
- checking them by code.
The same code for Save calls the event only when I click them with the
mouse. Looping through the rows with a for() doesn't do the expected
behaviour. What can I possibly do in the for() so that I misuse it?
The other page does the checking of the boxes in a javascript, that is
client side.

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>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" <da**********@rogers.comwrote in message
news:Oh**************@TK2MSFTNGP04.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:OL*************@TK2MSFTNGP03.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 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




Nov 13 '06 #17

P: n/a
If you want to try "call" the event directly, you're gonna to need the same
arguments that an event would provide. The tricky part of that will be the
"sender" object.

Using your example, you might be better off factoring out the event code
into a separate method that does not take "event-like" arguments (I note in
your case the method does not actually use the "sender" parameter) , and
have your event call that method. That way you can also call the same method
also.

Example

void ChangePage( int newPageIndex )
{
// Set CurrentPageIndex to the page the user clicked.
DataGrid1.CurrentPageIndex = newPageIndex;

// Rebind the data.
DataGrid1.DataBind( );
}

private void DataGrid1_PageIndexChanged(object source,
system.Web.UI.WebControls.DataGridPageChangedEvent Args e)
{
ChangePage( e.NewPageIndex );
}

// some other piece of code ...

ChangePage( the_new_page_number );

Kevin.

"Daniela Roman" <da**********@rogers.comwrote in message
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e)

{

// Set CurrentPageIndex to the page the user clicked.

DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.

DataGrid1.DataBind();

}

Under a button click event:

private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args e)

Thank you,

Daniela


Nov 19 '06 #18

P: n/a
Kevin,

Using a seperate method has the same evect as

TheMethod(null,null)

Cor

"Kevin Frey" <ke**********@hotmail.comschreef in bericht
news:ek**************@TK2MSFTNGP03.phx.gbl...
If you want to try "call" the event directly, you're gonna to need the
same arguments that an event would provide. The tricky part of that will
be the "sender" object.

Using your example, you might be better off factoring out the event code
into a separate method that does not take "event-like" arguments (I note
in your case the method does not actually use the "sender" parameter) ,
and have your event call that method. That way you can also call the same
method also.

Example

void ChangePage( int newPageIndex )
{
// Set CurrentPageIndex to the page the user clicked.
DataGrid1.CurrentPageIndex = newPageIndex;

// Rebind the data.
DataGrid1.DataBind( );
}

private void DataGrid1_PageIndexChanged(object source,
system.Web.UI.WebControls.DataGridPageChangedEvent Args e)
{
ChangePage( e.NewPageIndex );
}

// some other piece of code ...

ChangePage( the_new_page_number );

Kevin.

"Daniela Roman" <da**********@rogers.comwrote in message
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEven tArgs e)

{

// Set CurrentPageIndex to the page the user clicked.

DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.

DataGrid1.DataBind();

}

Under a button click event:

private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args e)

Thank you,

Daniela



Nov 20 '06 #19

P: n/a
Hi,

And just to add to Cor's response, neither approach will actually raise the event, which I believe
is what the OP was really after.

--
Dave Sexton

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Kevin,

Using a seperate method has the same evect as

TheMethod(null,null)

Cor

"Kevin Frey" <ke**********@hotmail.comschreef in bericht
news:ek**************@TK2MSFTNGP03.phx.gbl...
>If you want to try "call" the event directly, you're gonna to need the same arguments that an
event would provide. The tricky part of that will be the "sender" object.

Using your example, you might be better off factoring out the event code into a separate method
that does not take "event-like" arguments (I note in your case the method does not actually use
the "sender" parameter) , and have your event call that method. That way you can also call the
same method also.

Example

void ChangePage( int newPageIndex )
{
// Set CurrentPageIndex to the page the user clicked.
DataGrid1.CurrentPageIndex = newPageIndex;

// Rebind the data.
DataGrid1.DataBind( );
}

private void DataGrid1_PageIndexChanged(object source,
system.Web.UI.WebControls.DataGridPageChangedEven tArgs e)
{
ChangePage( e.NewPageIndex );
}

// some other piece of code ...

ChangePage( the_new_page_number );

Kevin.

"Daniela Roman" <da**********@rogers.comwrote in message
news:OO**************@TK2MSFTNGP03.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 PageIndexChanged event:

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEve ntArgs e)

{

// Set CurrentPageIndex to the page the user clicked.

DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.

DataGrid1.DataBind();

}

Under a button click event:

private void btnUpdtCmd_Click(object sender, System.EventArgs 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.DataGridPageChangedEvent Args e)

Thank you,

Daniela




Nov 20 '06 #20

This discussion thread is closed

Replies have been disabled for this discussion.