GridView - Editing

2 posts, 0 answers
  1. Srinivasan
    Srinivasan avatar
    3 posts
    Member since:
    Jan 2013

    Posted 29 Jan 2013 Link to this post

    I have gridview also binded  with DataTable. In the end of the right side, i have a pencil image to edit  By default the gridview will not allow Editing.




    If i click the pencil image then the row should allow editing (that selected row only).

    How to do this?

    How to enable editing for the current row?

    Thanks
    S.Srinivasan
  2. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 29 Jan 2013 Link to this post

    Hi,

    Thank you for writing.

    You can do that by modifying the Row.Tag in the CommandCellClick event handler and use this Tag in the CellBeginEdit event to determine whether to allow edit or not. Here is an example:
    void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
    {
        e.Cancel = !(e.Row.Tag == "AllowEdit");
    }
     
    GridViewRowInfo saveRowInfo;
    void radGridView1_CommandCellClick(object sender, EventArgs e)
    {
        if (saveRowInfo != null)
        {
            saveRowInfo.Tag = null;
        }
     
        GridCommandCellElement cell = (GridCommandCellElement)sender;
        cell.RowInfo.Tag = "AllowEdit";
        saveRowInfo = cell.RowInfo;
     
    }

    I hope this helps.
     
    Regards,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Back to Top