RE: ButtonColumn and EditCommandColumn don't work together as expected
- From: "Phillip Williams" <Phillip.Williams@xxxxxxxxxxxx>
- Date: Fri, 6 Jan 2006 09:34:01 -0800
The EditCommandColumn server control fires up the ItemCommand event just like
the Delete button does. What you need to do is to find out during the
ItemCommand handling which command was clicked. You should set the
OnItemCommand="DataGrid1_Command" and within that method:
protected void DataGrid1_Command(object sender, DataGridCommandEventArgs e)
{
switch (e.CommandName)
{
case "Delete":
//process the delete command
break;
}
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Piotr" wrote:
> Hi,
>
> I have a DataGrid with standard EditCommandColumn with PageIndex enabled.
> Everything works fine.
> When I add ButtonColumn
>
> <asp:ButtonColumn
> Text="Delete"
> HeaderText=""
> CommandName="Delete"/>
>
> and modify DataGrid with
>
> OnItemCommand="datagrid_Delete"
>
> strange things happen. It seems to work until I click one of "Edit" buttons.
> It changes properly to edit mode but then no matter what button I click next
> ("Cancel", "Update", some other "Edit" or one of page changing buttons) it
> always runs OnItemCommand, and what's very strange, CommandName property has
> always "Delete" value instead of "Cancel" , "Update" or whatever name of
> button I clicked:
>
> protected void datagrid_Delete(object o, DataGridCommandEventArgs e)
> {
> Response.Write("I clicked " + e.CommandName);
> ...
> }
>
> gives:
>
> I clicked Delete
>
> Strangly it works after another click...
> Why the h... is that?
>
> Thanks,
> Piotr
>
>
>
>
>
>
>
>
>
>
.
- Follow-Ups:
- References:
- Prev by Date: RE: Panel Syntax
- Next by Date: Re: Dynamically changing LinkButton properties
- Previous by thread: ButtonColumn and EditCommandColumn don't work together as expected in DataGrid
- Next by thread: Re: ButtonColumn and EditCommandColumn don't work together as expected
- Index(es):