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

Our retirement is, we need a search functionality and bind the data(Model binding) in to the table in our cshtml page.The process should through $ajax post method.

We tried to Implement according to the above requirements,As a result we could bind the model data in to our chtml page(While checking with Breakpoint we can make sure that data is binding into to each td).But the problem is ,The table are not displaying after binding the data

below is our controller

      public ActionResult Edit_cradholders(string fName,string surName, string cardHolderRef, string token, string cardHolderStatus)
              var id = (FormsIdentity)User.Identity;
      using (var db = new Entitityframework().Crunch_get_cardholder(0, fName, surName, cardHolderRef,token, cardHolderStatus, 0, 0, 0, "", "", 0, "", "")

            return View(db.ToList());
          catch (Exception)
            //  var filterContext = new ActionExecutingContext { Result = RedirectToAction("Login", "Login") };
              return View();// filterContext.Result;

Here is our view potion(just added only requirement potion)
@model IEnumerable<mvc3_crunch.models.crunch_get_cardholder_result>
 <table id="SearchResult1" class="table table-striped table-bordered table-condensed mGrid">
                        System reference
                    int i = 0;
                    if (Model != null)
                        foreach (var m in Model)
                           <div class="control-group">
                                <div class="controls">
                                    <div class="input-prepend">
           </tr>       </table>

Please help on this,
Thanks & Regards,
Updated 11-Dec-13 0:02am

1 solution

You are using ajax post that's why you html are not changing afte ajax post: so you can serialize you html like below:

$.post(homeUrl +"controller name/methodname", $("#billingaddressform").serialize(), function (response) {
Share this answer
soumyaraj 13-Dec-13 9:10am    
Many thanks for your response.
This is our common function for POST method
mvc3_crunch.common = {
PostData: function(requestUrl, dataStringified, options, onSuccess, onError) {
cache: false,
type: 'POST',
url: requestUrl,
data: JSON.stringify(dataStringified),
contentType: 'application/json; charset=utf-8',
dataType: json,
success: onSuccess,
error: onError
We are calling the function like below
mvc3_crunch.common.PostData('/CrunchDirect/Edit_cradholders', para, null, Onsucesscall, Onerrorcall);
Please specify How could I pass the Method using serialize ,which you mentioned on your

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