c# - Bind data to dynamically generated textbox in View using jquery - MVC -
in sql db have table projectid,taskid,workedhours,date fields , want bind workedhrs particular projectname,taskname in view. have table in view following :
@foreach (var item in model) { <tr style="background-color:#ded9d9;color:#000"> <td colspan="9" id="pn"> @html.displayfor(modelitem => item.project_name) @html.hidden("tprojectid", item.project_id) </td> </tr> <tr> <td style="padding-left:6%; width:22%;"> @html.displayfor(modelitem =>item.task_name) @html.hidden("ttaskid", item.task_id) </td> <td style=" width:7%;"> <input id="day1" name="day1" type="text" value="" style="width:70%;" disabled="disabled" /> </td> </tr> } i generate day1 textbox dynamically each project,task items in model. here want bind data dynamically generated textboxes. want fetch each row projectid/projectname,taskid /taskname match available values , bind data textboxes based on projectid.
how can achieve using jquery ....
can me this.... in advance...
i attached sample image of view
i data handler , bring view following :
$.ajax({ type: "get", url: "/infrastructure/handler/gettimsheetdata.ashx", data: "", success: function (response) { var temp; var pid; var tid; temp = json.stringify(response); var data = json.stringify(response); console.log('data: ' + data); $("#testtimesheetdata").append(data); } }); in side form, add table , bind response table
<table id="testtimesheetdata"></table> i planned projectid,taskid,workedhrs table , bind workedhrs appropriate textbox matching projeid,taskid in table
initially, bind data model controller using view bag following :
objparent = new testdao().gettimesheetprjectdetails(); viewdata["project"] = objparent;
Comments
Post a Comment