Click here to Skip to main content
15,030,320 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, sir

I am developing a mvc web application in mvc 3 razor and i want to send list(Grid View) object from view to Controller using ajax call in mvc.


$("#btnsave").click(function () {
var UserName = $("#UserName").val();
var Password = $("#Password").val();

url: '@Url.Action("Add_New_Access1", "Form")',
type: "GET",
data: { UserName: UserName, Password: Password, str: Gv_Table_List },
success: function (data) {
alert("Save", "Data Saved Successfully")

Here Gv_Table_List is my List Which I take instead of GridView

and what kind of type i should take in controller
for str
please help..
Updated 6-Jun-15 1:29am

1 solution

You use jquery function to do the call for submitting the data to the controller. Your function may look like this:
$('#YourLink').click(function () {      
        url: http://{hostname}/Person/Search,
        type: 'GET',
        data: { 
                id: "@ViewBag.ID",
                name: "@ViewBag.Name" 
        success: function () {
        error: function () {                

and in the controller call you can write as below to grab the data

public ActionResult Search(int id, string name)
   //Do the code for searching

Hope this will help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900