I have this mvc razor code where on click of button I am populating a dropdown ClinicIDSelect. Here I am comparing the selected value of another dropdown InvoiceSelect and data from Model and populating the ClinicIDSelect dropdown with filtered value.
<select class="form-control" id="ClinicIDSelect">
@foreach (DataRow r in Model.Tables["Clinic"].Rows)
{
var inv_nbr = @r["INVOICE_NBR"].ToString();
if ("inv_nbr" == $('#InvoiceSelect').val()) {
<option value="@r["CLINIC_CODE"]">@r["CLINIC_CODE"]</option>
}
}
</select>
The issue is - it seems that I cannot compare the inv_nbr(C# string) with a jquery value. It shows a small red squiggly underline in jquery .val() saying that $ unexpected character, invalid expression, ; expected, } expected.
What could be the options to achieve this ?