custom replacement of EditCommandColumn

N

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
 
B

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

BobU

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

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top