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

Show insert item form automatically when grid is loaded

2 Answers 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris McGrath
Top achievements
Rank 1
Chris McGrath asked on 28 Jan 2011, 10:29 PM
Hello,

I've got a grid with a custom EditForm in place for inserting records (update and delete are not allowed).  Rather than requiring the user to press the Add New Row button, I'd prefer to just have the edit form displaying by default when the screen loads.  They should be able to type in the form, commit it, and it will refresh itself with the new data and once again show another new item form.

I assumed there would be a C# command that I could call in Page_Load that would show this form but I was not able to find it.  I would highly prefer to do this in C# rather than calling the client-side API with Javascript.

I did begin to create a separate form outside of the grid, but because of my layout it really makes more sense for the insert form to be inside the grid control itself.

Thanks in advance to anyone who can tell me how to do this!

Chris

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 31 Jan 2011, 06:20 AM
Hello Chris,

Check out the following code snippet.
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
  {
      if (!Page.IsPostBack)
      {
          RadGrid1.MasterTableView.IsItemInserted = true;
          RadGrid1.Rebind();
      }
  }

Thanks,
Shinu.
0
Chris McGrath
Top achievements
Rank 1
answered on 31 Jan 2011, 04:55 PM
Thanks!  That did the trick.  I may have to play with it to make sure that the new item form shows up even after saving an item, but this should get me far enough to figure that bit out.
Tags
Grid
Asked by
Chris McGrath
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Chris McGrath
Top achievements
Rank 1
Share this question
or