This is a migrated thread and some comments may be shown as answers.

[Solved] Place grid in Edit mode

1 Answer 213 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vinny
Top achievements
Rank 1
Vinny asked on 12 Feb 2008, 09:33 PM
Hello,
I have a button in a template column. When clicked I would like to show the contents of the EditItemTemplate. When clicked again, I'd like to hide the contents. Can someone instruct me on how to achieve this? Also, how can I remove the Update and Cancel link buttons that appear automatically in the EditItemTemplate?

Thank you!

1 Answer, 1 is accepted

Sort by
0
Vinny
Top achievements
Rank 1
answered on 13 Feb 2008, 07:44 PM
Figured it out for those interested.

protected void myGrid_ItemCommand(object source, GridCommandEventArgs e)
{
    if (e.CommandName == "View")
    {
        
if (!(myGrid.MasterTableView.Items[e.Item.ItemIndex].Edit == true))
        {
            
// item is not in edit mode so place the grid in edit mode.
            //
the item index is added to the EditIndexes collection
            // of the grid to handle multi row editing. The AllowMultiRowEdit
            // property of the grid should be set to true for this to work.
            // If not, then only one row can be in edit mode at a time.
            
myGrid.EditIndexes.Add(e.Item.ItemIndex);
            myGrid.MasterTableView.Items[e.Item.ItemIndex].Edit =
true;
        }
        else
        
{
            // user clicked button for item in edit mode so exit edit mode
            myGrid.MasterTableView.Items[e.Item.ItemIndex].Edit =
false;
        }
        myGrid.Rebind();
}

Tags
Grid
Asked by
Vinny
Top achievements
Rank 1
Answers by
Vinny
Top achievements
Rank 1
Share this question
or