lundi 3 avril 2017

Get database Value in textboxFor in bootstrap modal popup in MVC

I place a text box in the bootstrap modal popup and also I have a kink in the table data in the table come from database so I want when I click pop-up show database cell value in the textbox that exists in the modal-popup. Below is my code

Thats my action method that gets data and data is passing to the ViewBag.Type

public JsonResult LinkButton(int RoelID)
    Role model = new Role();
    Session["State"] = RoelID;
    int id = RoelID;
    RoleServices ser = new RoleServices();
    var data = ser.Get(id);          
    bool result=false;
        ViewBag.Type = data.RoleType;
    return Json(result, JsonRequestBehavior.AllowGet); 

Here is a code of JQuery and Ajax acall the action method on link click

<a href="#"  onclick="UpdateID(@item.RoelID)">Select</a>

    var UpdateID = function (RoelID) {
        var roleID=$("#hiddenID").val();
            type: "post",
            url: '@Url.Action("LinkButton", "Account")',
            data: { RoelID: roleID },

Here is textBox in the Modal PopUp

@Html.TextBoxFor(model => model.RoleType, new { @value=ViewBag.Type })

Aucun commentaire:

Enregistrer un commentaire