Re: How to call 2 events inside the datagrid



hi velu,
firstly i should point out that double-clicking on a web page is usually not
what you want. it just performs the same request twice, and you miss the
response from the first one because by clicking it a second time, the
browser aborted that request and initiated a second one. the first request
may or may not be executed fully.

do you want the second button to perform a different command when it is
clicked? if so you should set the CommandName on the button (in the aspx)
to a different command. e.g. the Edit button should have CommandName=Edit.
the Delete button should have CommandName=Delete.
then the DataGrid1_ItemCommand will be able to determine which button was
clicked, and act appropriately.

if you want the same button to do two tasks, you could just combine those
tasks in the DataGrid1_ItemCommand method. or if you specifically want the
DataGrid1_ItemCommand method to be invoked twice, with 2 different
commandNames, based on one button click... you could call the function a
second time, creating new event args, with the new command name, as shown
below.

here is some code, although it doesn't make much sense to invoke the
ItemCommand twice, you should really just separate the commands into
functions, and call the function instead of trying to simulate a new
ItemCommand on the datagrid:

private void DataGrid1_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
switch(e.CommandName)
{
case "Delete":
// insert delete code here
// ...

// now invoke the 'Command2' command, by calling this method again, with
new event args
this.DataGrid1_ItemCommand(source, new DataGridCommandEventArgs(e.Item,
e.CommandSource, new CommandEventArgs("Command2","")));
break;


case "Edit":
break;


case "Command2":
// execute command2...
break;
}
}

maybe you could clarify exactly what you want to do, and we can take it from
there.

thanks

tim


--------------------------
blog: http://tim.mackey.ie

"velu" <velu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:927D52D1-96CF-41CE-A1D4-A828DA697FB6@xxxxxxxxxxxxxxxx
>I have fetched a query in to the datagrids. Now I have added a new column
>to
> the existing table (to the datagrid.)
> In the new column I have placed 2 buttons. So when I click the first
> button
> it performs some set of instruction. I actually made use of this procedure
> DataGrid1_ItemCommand.
>
> Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
> System.Web.UI.WebControls.DataGridCommandEventArgs)
> End Sub
>
> Now my question is how will able to use the other one? coz when I double
> click the second button, it is nowhere land me in to a new procedure..
>
> Let me know you thoughts..
>


.


Loading