edit button in datagrid

  • Thread starter Thread starter Matt Tapia
  • Start date Start date
M

Matt Tapia

I want to add a button within an Item Template column that will set the edit
mode for the current item in the grid. can anyone tell me how to do it
without adding an edit command column?

Thanks!
 
I want to add a button within an Item Template column that will set the
edit
mode for the current item in the grid. can anyone tell me how to do it
without adding an edit command column?

Setting the edit item is as straightforward as datagrid.EditItemIndex =
<whatever value you want>

So, in essence, you just need a button to post back, and then handle this
post back in an event handler that sets the EditItemIndex. Using an edit
command grid makes this easier, because you can then trap the EditCommand
event handler and use the DataGridCommandEventArgs e.Item.ItemIndex to get
this value. But once you roll a mechanism to determine what row should be
edited, it's just a single line of code to set this row into edit mode.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
 
Back
Top