Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have three dropdowns all are coming from partialview .....first and sec dropdown load on page load, third one depends upon passing first and second dropdown value as parameter in third but as I am not using any event on first or loading third one on the click of second dropdown I am only getting second dropdwon value in parameter not first one, can anyone help me in same... I am using Ajax.BeginForm in dropdownlist.

First DropDown

@Html.DropDownListFor(
m => m.SelectedYearId,
new MultiSelectList(ViewBag.Years,"YearID", "Years"),
"Select Year",new { Multiple = "multiple", @class = "multiselect", style = "width: 250px"}
)

Second Drop Down
@model WebReports.Models.Entities

@using (Ajax.BeginForm("LoadCompbyMatchType", "ICC", new AjaxOptions { UpdateTargetId = "Comp" }))
{

@Html.HiddenFor(m => m.SelectedYearId)
@Html.HiddenFor(m => m.SelectedReportId)
@Html.DropDownListFor(
m => m.SelectedMatchTypeId,
new MultiSelectList(ViewBag.MatchType, "MatchTypeID", "MatchTypeName"),
"Select a Match Type",new { Multiple = "multiple", @class = "select", style = "width: 250px"}
)

}

Third Drop Down

@if (ViewBag.Comp != null)
{
using (Ajax.BeginForm("LoadMatchbyComp", "ICC", new AjaxOptions { UpdateTargetId = "Match" }))
{

@Html.HiddenFor(m => m.SelectedYearId)
@Html.HiddenFor(m => m.SelectedMatchTypeId)
@Html.DropDownListFor(
m => m.SelectedCompId,
new SelectList(ViewBag.Comp,"CompetitionID", "CompetitionName"),
string.Empty
)

}

}

<script type="text/javascript">
$('#SelectedCompId').change(function ()
{
$(this).parents('form').submit();
});
</script>

<script type="text/javascript">
$('#SelectedMatchTypeId').change(function ()
{
$(this).parents('form').submit();
});


[HttpPost]
public ActionResult LoadCompbyMatchType(IEnumerable(string) SelectedMatchTypeId, IEnumerable(string) SelectedYearId)
{

}


Not Able to get SelectedYearId
Posted
Comments
Mehdy Moini 16-Sep-13 7:29am    
If you want a global parameter you can put your variable in viewbag, but i couldn't understand your problem clear!
TryAndSucceed 16-Sep-13 12:27pm    
I think you will get it back in Model. Try using Model in your post.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900