How to pass dropdownselected value in Ajax Begin Form [Resolved]

Posted by Self-Innovator under ASP.NET AJAX on 5/11/2016 | Points: 10 | Views : 709 | Status : [Member] | Replies : 1
Hi All,

I wanted to pass Drop down list selected value in Ajax begin from kindly help,

Below is my code

@using (Ajax.BeginForm("AddNewStore", "StoreRegistration", new AjaxOptions { HttpMethod = "POST", OnSuccess = "successOfAddition", OnFailure = "failureOfAddition" }, new { id = "addStoreRegisterForm" }))
{
<div class="form-group col-md-6">
<div class="form-group">
<!--[if gte IE 9]><div class="input-group"><span class="input-group-addon">Store Number</span><![endif]-->
@*<input type="text" placeholder="Store Number" value="" name="storeno" class="form-control" />*@
<!--[if gte IE 9]></div><![endif]-->
@Html.DropDownListFor(x => x.StoreRegistrationAssociation.StoreIdentity, new SelectList(Model.StoreRegistrationAssociation.StoreIdentity, "Code", "Name", Model.StoreRegistrationAssociation.StoreIdentity), "Please Make a Selection", new { @class = "form-control", placeholder = "Please Make a Selection" })
@Html.ValidationMessageFor(x => x.StoreRegistrationAssociation.StoreIdentity)
</div>
</div>

<div class="form-group col-md-6">
<div class="form-group">
<!--[if gte IE 9]><div class="input-group"><span class="input-group-addon">Store Number</span><![endif]-->
@*<input type="text" placeholder="Store Number" value="" name="storeno" class="form-control" />*@
<!--[if gte IE 9]></div><![endif]-->
@Html.TextBoxFor(x => x.StoreRegistrationAssociation.StoreNumber, new { @class = "form-control", placeholder = "Store Number" })
@Html.ValidationMessageFor(x => x.StoreRegistrationAssociation.StoreNumber)
</div>
</div>
}


<div class="form-group">
<input type="reset" value="Cancel" />
<button type="submit" class="red-btn" data-dismiss="modal" id="btnRegisterStore">Agree</button>
</div>


On my button click i'm getting a store identity value as count =0 instead of selected value kindly help,

I have tried using ajax call i'mm getting the selected value but i'm not aware how to pass the selected value to form
   @Html.DropDownListFor(x => x.StoreRegistrationAssociation.StoreIdentity, new SelectList(Model.StoreRegistrationAssociation.StoreIdentity, "Code", "Name", Model.StoreRegistrationAssociation.StoreIdentity), "Please Make a Selection", new { @class = "form-control",id="ddlIdentity", placeholder = "Please Make a Selection" })


function AdditionalsChanged() {
selIdentity = $("#ddlIdentity").val();
$("#ddlIdentity").val(selIdentity);
}


Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Sheonarayan on: 5/11/2016 [Administrator] HonoraryPlatinum | Points: 50

Up
0
Down

Resolved
Difficult to guess however will suggest few points to track down the issue.

1. See the View Source of the web page and see if the dropdown options value are different for each item or somehow all are coming as 0 OR what is the name of the dropdown coming in and are you trying to get the same dropdown in the server side.

2. Remove the Ajax.BeginForm and instead use Html.BeginForm and see if it makes any difference.

My guess is that your dropdown items population is not correct.

Hope this helps.
Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response