|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
custom replacement of EditCommandColumnI 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 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 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 > > >
populating a datagrid
How can I display hashtable key values in a web page? Move bound column to right of dynamic column in datagrid? assigning itemtemplate, edititemtemplate programmatically Label text from template column is blank in ItemCommand event problem exporting datagrid to excel Trying to implement master/detail with 2 datagrids can i use dynamic variable inside a dataadapter and bind to datagrid How to pull the data out from two table and bind to repeater User Control |
|||||||||||||||||||||||