Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

Can anyone help and guide me to do JQuery - based data listing without page refreshing in MVC4. Data in the grid has to be automatically refreshed.

I have data listing view in which i have user data:
Name
Username
Password
Then i also have a buuton in that view. When i click that button a popup comes and i can enter new user in it and save. When i save data should be automatically refreshed in grid.


Please anyone help me.
Posted

1 solution

You need to change the call to Ajax and also you need to put the Grid in partial view and load the Partial View using Ajax.The below link will help you to load the grid data by using Ajax.
http://fromjami.wordpress.com/2013/05/26/load-partial-view-as-html-by-using-jquery-ajax-in-asp-net-mvc/[^]

Hope this helps
 
Share this answer
 
Comments
Minnu Sanju 24-Jul-13 3:59am    
thank u jameel
Minnu Sanju 24-Jul-13 6:55am    
if ur not bsy can u please help me

in my controller i have:
public ActionResult UserListing()
{
DataTable dt = new DataTable();
dt=sampleDal.UserRetrieve();
return PartialView(ConvertDataTabletoIEnumerable(dt));
}

private IEnumerable<sample> ConvertDataTabletoIEnumerable(DataTable dataTable)
{
foreach (DataRow row in dataTable.Rows)
{
yield return new Sample
{
Name=row["Name"].ToString(),
UserName = row["UserName"].ToString()
};
}
}


And in View

@using (Html.BeginForm("AddUser", "Sample", FormMethod.Post))
{
<input type="submit" id="adduser" value="Add New User" style="color:gray; border-bottom-style:solid; border-right-style:solid; margin-left:1100px;" />
}

<div id="result">
@{
var grid = new WebGrid(Model, defaultSort: "Name", rowsPerPage: 10, canPage: true);
}
@grid.GetHtml(
columns: grid.Columns(
grid.Column("Name", "Name", canSort: false),
grid.Column("Username", "Username", canSort: false)
), tableStyle: "list",footerStyle:"foot",nextText:"Next", previousText:"Previous"
)
</div>


when i click on Add New user a popup should appear to enter new user
please suggest me the code for that
Jameel VM 24-Jul-13 7:23am    
is the ajax load works?
Jameel VM 24-Jul-13 7:25am    
Please post this question as a separate thread
Minnu Sanju 24-Jul-13 8:00am    
no

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