TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anele Ngqandu
1.3k
431
29.3k
How to fix my search using a select that is populated razor
Apr 22 2019 12:44 PM
A select populated using razor
<
select
placeholder
=
"Select campus"
id
=
"selCampus"
class
=
"form-control"
required
>
<
option
value
=
""
>
Select campus
</
option
>
@foreach (var campus in Model.Campuses)
{
<
option
value
=
"@campus.Id"
>
@campus.CampusName
</
option
>
}
</
select
>
Onchange for the select pointing to the action controller
$(
"#selCampus"
).change(
function
() {
//$(".employee").remove();
$.ajax({
type:
'POST'
,
url:
'/admin/staff/'
,
dataType:
'html'
,
data: ({
campusId: $(
this
).val()
}),
success:
function
() {
}
});
});
ActionResult, this loads on pageload and onchange of the select
public
ActionResult Employees(
long
? campusId)
{
var client =
new
RestClient(Request.Url.GetLeftPart(UriPartial.Authority).ToString());
var request =
new
RestRequest(
"api/employee/getClinicMembers/{campusId}"
, Method.POST);
request.AddParameter(
"campusId"
, campusId, ParameterType.QueryString);
var result = client.Execute
(request);
ViewBag.title =
"Home | Members"
;
return
View(result.Data);
}
Does not want to redraw this code with new data, Even tho Model.Employees has filtered data
@foreach (var member in Model.Employees)
{
<
div
class
=
"col-lg-4 col-xlg-3 col-md-5 employee"
>
<
div
class
=
"card"
>
<
div
class
=
"card-body"
>
</
div
>
</
div
>
</
div
>
}
Reply
Answers (
2
)
0
Anele Ngqandu
1.3k
431
29.3k
Apr 25 2019 7:47 AM
No, no new data in the dropdown. The only new data will be the data from "
Model.Employees".
0
Jenith Thakkar
339
5k
29.5k
Apr 23 2019 4:13 AM
just for confirmation
When you create a new employee at that time a new data not bound on that drop-down list right?
Regarding multiple array passing to single method.
Need OAuth authorization sample code