edit button in datagrid

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!
 
C

Chris Jackson

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

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top