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

[Solved] Pass grid data back to controller

2 Answers 185 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
quynh
Top achievements
Rank 1
quynh asked on 24 Feb 2011, 01:35 AM
I have a grid where i edit and insert data. On .DataBinding(dataBinding => dataBinding.Ajax().Select i want to pass the grid data back to the controller.  Is this possible? 

here is my code: 
var grid = $("#GridEventDetail").data("tGrid").data;
$("#GridEventDetail").data("tGrid").rebind({ grid : grid });

here is the databinding on my grid
.DataBinding(dataBinding => dataBinding.Ajax().Select("_SelectEventData", "Event")

in my controller i want to get the rows from my grid:
[GridAction]
public ActionResult _SelectEventData</span>(List<MyViewDataModel> grid)
{
     string field1 = grid.field1;
     DateTime field2 = grid.field2;

My reason for doing this is to avoid using Session. I want to preserve the data until the user is ready to submit to the database.

2 Answers, 1 is accepted

Sort by
0
Rijaz
Top achievements
Rank 1
answered on 22 Mar 2011, 09:15 AM
I am also trying the same facility. If there is a way to get all rows displayed in the grid in the controller, Please help.

Thanks in Advance.
0
Cheng
Top achievements
Rank 1
answered on 07 Mar 2012, 05:16 PM
hello, I'm also trying to post back whole grid to controller, is there anyone can gives me some ideas?
I think if I generate form by simple html, such as 
@using (Html.BeginForm())
{
    @foreach (var item in ViewBag.Items)
    {
        <tr><td>item.Property1</td><td>item.AnotherProperty</td></tr>
    }
}

then may I can get table data from Request.Forms["xxx"], but I think it's not easy to code, and I'm using Telerik.Grid.

Is there a simple way to post back whole table to controller? and how can I get this data in controller?

Thanks
Tags
General Discussions
Asked by
quynh
Top achievements
Rank 1
Answers by
Rijaz
Top achievements
Rank 1
Cheng
Top achievements
Rank 1
Share this question
or