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

IsItemInserted always set to false after InsertCommand

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew Jacks
Top achievements
Rank 1
Andrew Jacks asked on 02 Sep 2010, 08:34 AM
G'Day,

I have a grid, which I always want to show the Insert Row, except when another row is being edited.

So far I have set the IsItemInserted to true or false during the NeedDataSource event and everything works as expected,. That is until I save a new item. Then the Insert row is removed.

It looks like property is being set to false After the NeedDataSource event and Before the Grid Pre-Render event. Can anyone tell me how I can override this property being reset to False?

I do have a workaround, but it is a little clunky.

I check it's status in the Grid_PreRender, if false I then reset it to be true and then force a ReBind.

Thanks

Andrew

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Sep 2010, 10:17 AM
Hello Andrew,

In order to show insertform always (unless editform is displayed), try the following code snippet in PreRender event than in NeedDataSource event.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
   {
       if (RadGrid1.EditIndexes.Count == 0)
       {
           RadGrid1.MasterTableView.IsItemInserted = true;
       }
       else
       {
           RadGrid1.MasterTableView.IsItemInserted = false;
       }
       RadGrid1.MasterTableView.Rebind();
   }

Thanks,
Princy.
Tags
Grid
Asked by
Andrew Jacks
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or