我有一个下拉列表。下拉选择从数据库中获取值,在字符串值无法分配给文本框之后。
我的控制器
[HttpPost]
public ActionResult GetCountryBasedCharge(Int64 ID)
{
OrderBilling objOrderBilling = new OrderBilling();
OrderBilling objCalculate = new OrderBilling();
objCalculate = objOrderBilling.AutoCompleteState(ID);
string chargeid =Convert.ToString(objCalculate.ShippingCharge);
return Content(chargeid);
}
我的观点
@Html.DropDownList("Country", (IEnumerable<SelectListItem>)ViewBag.countrytitles,
"-----------Select----------"
, new { id = "txtBCountry", @class = "selectStyle" })</td><td><label style="color:red" >*</label>
<input type="text" class="textbox" id="txtChargeAmts" />
<script type="text/javascript" >
$(document).ready(function () {
var CountryID;
$(function () {
$("#txtBCountry").change(function () {
CountryID = $("#txtBCountry option:selected").val();
$.ajax({
type: "POST",
url: '../Billing/GetCountryBasedCharge',
data: { ID: CountryID },
success: function (data) {
if (data) {
alert(data);
**$('#txtChargeAmts').html(data);**
}
}
});
});
});
</script>