Skip to main content

Posts

Convert DataSet to C# List

You can simply try like this public static List<AttendenceManual> PreocessData(DataSet data) { List<AttendenceManual> _AttendenceManualList = new List<AttendenceManual>(); for (int i = 0; i < data.Tables[0].Rows.Count; i++) { AttendenceManual Student = new AttendenceManual(); Student.StrEmpID = data.Tables[0].Rows[i]["F2"].ToString(); _AttendenceManualList.Add(Student); } return _AttendenceManualList; }

MVC CheckBoxFor value set from script

If we want to set value in CheckBoxFor value from script we can set value like this: function EditAccessPrevilige(AccessPrivilegeID, LoginID, EmployeeAccessPrivilege, PayrollPrivilege) { $('#AccessPrivilegeInfo_LoginID').val(LoginID); if (EmployeeAccessPrivilege == "True") document.getElementById("AccessPrivilegeInfo_EmployeeAccessPrivilege").checked = true; else document.getElementById("AccessPrivilegeInfo_EmployeeAccessPrivilege").checked = false; if (PayrollPrivilege == "True") document.getElementById("AccessPrivilegeInfo_PayrollPrivilege").checked = true; else document.getElementById("AccessPrivilegeInfo_PayrollPrivilege").checked = false; return false; }

mvc razor textboxfor change event change another textboxfor value

Based on value of Weight, Rate , CNF & AWB it will change the value of Freight , TTLCNF anfd TTLFright . Freight= Weight*Rate; TTLCNF  = Weight*CNF; TTLFright=  Freight+ TTLCNF  + AWB; @Html.TextBoxFor(model => model.Weight, new { onChange="return GetWight(this);"}) @Html.TextBoxFor(model => model.Rate, new { onChange="return GetWight(this);"})/Kg @Html.TextBoxFor(model => model.Freight, new {disabled = "disabled" , @readonly = "readonly" ,onChange="return GetTTLFright(this);"}) @Html.TextBoxFor(model => model.CNFPK, new { onChange="return GetCNFPK(this);"}) @Html.TextBoxFor(model => model.TTLCNF, new {disabled = "disabled" , @readonly = "readonly",onChange="return GetTTLFright(this);" }) @Html.TextBoxFor(model => model.AWB, new { onChange="return GetTTLFright(this);"}) and script <script> function GetW...

MVC razor table row date to compare date between other 2 date in javascript

Consider the senerio of the image that i want to select date from table row date and my selected date will check other 2 date between in javascript. First i am getting the event of date change: </td> <td class="rptrowdata" align="center" style="width: 65px"> @{ if (Model.EmployeeInformationList[i].OutGoingDate == DateTime.MinValue || Model.EmployeeInformationList[i].OutGoingDate == null) { @Html.TextBoxFor(m => m.EmployeeInformationList[i].strOutGoingDate, new { @class = "textRegular dtPicker pmtallocated pull-right", @readOnly = "readOnly", maxlength = "10",@dir = "rtl",@onchange = "return DateChecker(this);" }) } else { <input type="hidden" value="@Model.EmployeeInformationList[i].Out...

mvc controller post action not working

some times we see that the post is not work, like as button or other. we can manage it using form and script to serialize the form to reach our controller action. define your action path, form id and method type in your form. <form id="subscriptionForm" action="/Category/Create" method="post">   <div class="form-horizontal"> <h4>PIS_tblCategory</h4> <hr /> @Html.ValidationSummary(true) <div class="form-group"> <div class="form-group"> @Html.LabelFor(model => model.CategoryName, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.CategoryName) @Html.ValidationMessageFor(model => model.CategoryName) </div> </div> <div class="form-group"> @Html.LabelFo...