Professional Web Applications Themes

custom replacement of EditCommandColumn - ASP.NET Data Grid Control

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...

  1. #1

    Default custom replacement of EditCommandColumn

    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


    news.microsoft.com Guest

  2. #2

    Default Re: custom replacement of EditCommandColumn

    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
    [url]http://staff.develop.com/ballen[/url]


    > 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


    Brock Allen Guest

  3. #3

    Default Re: custom replacement of EditCommandColumn

    Thanks. I've started going down the path of just handling the dropdownlist
    event as you suggested.

    Bob

    "Brock Allen" <ballenNOSPAMdevelop.com> wrote in message
    news:296989632477087893936032msnews.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
    > [url]http://staff.develop.com/ballen[/url]
    >
    >
    >
    >> 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
    >
    >
    >

    BobU Guest

Similar Threads

  1. EditCommandColumn Footer
    By DougSain in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: February 21st, 03:54 AM
  2. EditCommandColumn Icon?
    By Rock in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: January 7th, 03:03 AM
  3. Footer to asp:EditCommandColumn
    By Vishal in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: November 5th, 12:25 AM
  4. EditCommandColumn
    By Vanessa Berni in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: October 9th, 03:40 AM
  5. Custom replacement function
    By Robert Scheer in forum Microsoft SQL / MS SQL Server
    Replies: 1
    Last Post: June 30th, 07:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139