2文本框填写MVC中的dropdown选择 [英] 2 textbox fill on dropdownselection in MVC

查看:69
本文介绍了2文本框填写MVC中的dropdown选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在下拉列表的选项中填写数据库中的两个文本框。



我尝试了什么:



任何人都可以给我这个问题的演示。我在这里坚持。我尽我所能。但没有得到输出。

i want to fill two textboxes from database on the seletion of dropdownlist.

What I have tried:

can anyone give me demo on this question. i am stucking here.i tried my best.but not getting output.

推荐答案

试试这个



try this

public ActionResult GetValuesFromDatabase(string inputId)
      {
          int inputid = Convert.ToInt32(inputId);
          using (AccountDBEntities2 acc = new AccountDBEntities2())
          {
              var item = acc.tbl_CustomerCreation.FirstOrDefault(k => k.Account_No == inputid);
              if (item != null) return Json(item);
              else
                  return null;
          }
      }




ajax成功方法中的






in the ajax success method:

      success: function(response) {
//assign values to your textboxes.


#CustomerName)。val(response.Customer_Name);
("#CustomerName").val(response.Customer_Name);


#Address)。val(response.Billing_Address);
}
("#Address").val(response.Billing_Address); }


这篇关于2文本框填写MVC中的dropdown选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆