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

Dynamic Control + RadGrid + NeedDataSource + Postback

2 Answers 204 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike Bridge
Top achievements
Rank 1
Mike Bridge asked on 28 Mar 2011, 07:29 PM
Hi-

I have a radgrid which is supposed to always have a new item in edit mode at the bottom of the list.  The radgrid uses NeedsDataSource to do databinding, and I'm calling IsItemInserted = true during the OnNeedsDataSource callback.  This worked fine until I added a dynamically created Control in my OnItemDataBound call.  This inserts a control of some kind into the RadGrid, but it disappears on postback.   I figure I have to call Rebind somewhere so I can recreate this control. buy when I call Rebind from PageLoad or my OnInsertCommand, I can't seem to keep IsItemInserted=true---my editable row disappears.  My question is, where should I put Rebind() and IsItemInserted=true so that I can keep an Insertable row visible at the bottom of the grid at all times, while still being able to keep my dynamic control around?

Thanks!

-Mike

<telerik:RadGrid
                AutoGenerateColumns="False"
                ID="radGrid"
                runat="server"
                Skin=""
                ...
                OnNeedDataSource="radGrid_NeedDataSource"
                OnItemDataBound="radGrid_ItemDataBound"

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 29 Mar 2011, 08:08 AM
Hello Mike,

In PreRender event, try to put the grid in insert mode like below.

C#:
protected void radGrid_PreRender(object sender, EventArgs e)
   {
         radGrid.MasterTableView.IsItemInserted = true;
         radGrid.MasterTableView.Rebind();
   }

Thanks,
Princy.
0
Mike Bridge
Top achievements
Rank 1
answered on 01 Apr 2011, 08:06 PM
That appears to work thanks!
Tags
Grid
Asked by
Mike Bridge
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mike Bridge
Top achievements
Rank 1
Share this question
or