hi i am created search function what result comes and i am doing filtering the result like country wise, state and city etc using Checkboxes so when select multiple country and passing the values to Controller by using the Jquery and Ajax so here my
View
<div class="col-2 py-1 fa fa">
@foreach (var item in ViewBag.states)
{
<label><input type="checkbox" name="rocName" id="rocName" class="roc" state="@item" checked="checked" />@item</label>
}
</div>
<script type="text/javascript">
$(document).ready(function () {
debugger;
var ROC_Code; var ROC = "RoC-";
var Name;
$('.roc').on("change", function () {
var strms = [];
$('input:checked').each(function () {
Name = $(this).attr("state");
if (Name != null) {
ROC_Code = ROC + Name;
}
strms.push(ROC_Code);
});
$.ajax({
type: "POST",
url: '@Url.Action("BasicSearch","Home")',
dataType: "html",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ STRMSSelected: strms }),
success: function (data) {
$("#_companyList").html(data);
}
});
});
});
Controller
public PartialViewResult BasicSearch(IEnumerable<string> STRMSSelected, FormCollection collection, string currentFilter, int? page)
{`Companies = (from cindata in _db.CIN_Data
join masdata in _db.CompanyMasterDatas on cindata.CIN_FCRN_LLP_FLLP equals masdata.CIN_LLPIN_FCRN
where states.Contains(masdata.ROC_Code)
&& cindata.CompanyName_LLP.Contains(searchString)
&& masdata.Company_LLP_Status == "Active"
select new ListCompanyViewModel
{
CompanyName = cindata.CompanyName_LLP,
CIN_No = masdata.CIN_LLPIN_FCRN,
Status = masdata.Company_LLP_Status,
IndustryType = cindata.ActivityDescription
}).ToList();`
}
the code was excuting properly but i am getting 0 record, so is there any wrong in code.
Comments
Post a Comment