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

RadGrid & Insert form in codebehind

2 Answers 192 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alessandro
Top achievements
Rank 1
Alessandro asked on 11 Jul 2012, 09:08 AM
Hi all, i have a problem with RadGrid.

When i enter into a page where there is a RadGrid, i want that RadGrid Insert Form is opened.

I have looked for on the forum but i didint find any solution for my problem.

I tryed what you suggested in the following forum

http://www.telerik.com/community/forums/aspnet/grid/i-want-call-radgrid1-insertcommand-from-a-button-out-of-rad-grid.aspx#484224

but my case is a bit different.


I have tryed to call

radgrid1.Items[0].FireCommandEvent("InitInsert", string.Empty)

in Page_Load and this works if i have at least 1 item. If my RadGrid is empty, it fires and exception because the radgrid1.Items[0] doesn't exist. Can you give me a little advice?

Many thank
Alessandro

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Jul 2012, 09:15 AM
Hi,

Try the following code snippet to make the RadGrid in Insert mode on page load.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    RadGrid1.MasterTableView.IsItemInserted = true; // Check for the !IsPostBack also for initial page load
    RadGrid1.Rebind();
}

Thanks,
Shinu.
0
Alessandro
Top achievements
Rank 1
answered on 11 Jul 2012, 10:12 AM
Ok, this worked for me.

Many thx
Tags
Grid
Asked by
Alessandro
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Alessandro
Top achievements
Rank 1
Share this question
or