Home All Groups Group Topic Archive Search About

custom replacement of EditCommandColumn

Author
29 Mar 2005 7:45 PM
news.microsoft.com
I want to use the Edit-Update-Cancel workflow functionality built into the
DataGrid but instead of using an EditCommandColumn to display a button or
link to trigger the EditCommand event firing, I want to trigger that event
on a particular selection from a DropDownList within one of the columns. I
haven't seen any way to replace the built-in EditCommandColumn to do this.
Does anyone have any ideas?

Thanks,
Bob

Author
29 Mar 2005 9:00 PM
Brock Allen
You simply need to handle the server side event for the DropDownList and
then set the DataGrid.EditItemIndex appropriately. The downside is that the
DropDownList has no event bubbling on the server so you won't be able to
handle the DataGrid.ItemCommand event, so you'll need to sort of hack it:

private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
    Control parent = (Control)sender;
    while (parent.GetType() != typeof(DataGridItem))
    {
        parent = parent.Parent;
    }
    DataGridItem item = (DataGridItem)parent;
    item.ItemIndex;
}

This snippet is just off the top of my head, so you should work through it
yourself to make sure it's correct.

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> I want to use the Edit-Update-Cancel workflow functionality built into
> the DataGrid but instead of using an EditCommandColumn to display a
> button or link to trigger the EditCommand event firing, I want to
> trigger that event on a particular selection from a DropDownList
> within one of the columns. I haven't seen any way to replace the
> built-in EditCommandColumn to do this. Does anyone have any ideas?
>
> Thanks,
> Bob
Author
29 Mar 2005 9:19 PM
BobU
Thanks. I've started going down the path of just handling the dropdownlist
event as you suggested.

Bob

Show quoteHide quote
"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
news:296989632477087893936032@msnews.microsoft.com...
> You simply need to handle the server side event for the DropDownList and
> then set the DataGrid.EditItemIndex appropriately. The downside is that
> the DropDownList has no event bubbling on the server so you won't be able
> to handle the DataGrid.ItemCommand event, so you'll need to sort of hack
> it:
>
> private void DropDownList1_SelectedIndexChanged(object sender,
> System.EventArgs e)
> {
> Control parent = (Control)sender;
> while (parent.GetType() != typeof(DataGridItem))
> {
> parent = parent.Parent;
> }
> DataGridItem item = (DataGridItem)parent;
> item.ItemIndex;
> }
>
> This snippet is just off the top of my head, so you should work through it
> yourself to make sure it's correct.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
>> I want to use the Edit-Update-Cancel workflow functionality built into
>> the DataGrid but instead of using an EditCommandColumn to display a
>> button or link to trigger the EditCommand event firing, I want to
>> trigger that event on a particular selection from a DropDownList
>> within one of the columns. I haven't seen any way to replace the
>> built-in EditCommandColumn to do this. Does anyone have any ideas?
>>
>> Thanks,
>> Bob
>
>
>