yes sir ................you are right ...........i have done that work but the selected item is value for eg .....1, but i want text of that item like india.
{ var opt = new Option(data[i].Text,data[i].Value); $('#appearing_class').append(opt); }
},
error: function (ex) {
alert('Failed to retrieve values.' + ex);
}
});
}
First dropdownlist.................
Select Course
@Html.DropDownListFor(model => model.course,
new List
{
new SelectListItem{Value="0",Text="Select"},
new SelectListItem{Value="1",Text="MBA"},
new SelectListItem{Value="2",Text="B.TECH"},
new SelectListItem{Value="3",Text="POLYTECHNIC"}
}, new { @class = "span6", @onchange = "SelectedIndexChanged()" })
Second Dropdownlist..........
IF You Are Appearing Condidate
@if (ViewBag.gc != null)
{
@Html.DropDownListFor(model => model.appearing_class, new SelectList(ViewBag.gc as System.Collections.IEnumerable, "appearing_class", "appearing_class"),"Select")
}
controller code:
public JsonResult GetClass(string Candidate_Id)
{
List gc = new List();
if (Candidate_Id != "0")
{
if (Candidate_Id == "1")
{
gc.Add(new SelectListItem { Text = " Appearing In Graduation", Value = "1" });
one is using jquery or you can bind it from controller,
find the code for controller ,
public ActionResult Edit(int id)
{
OurDBContext db = new OurDBContext();
NewResourceRequest newresourcerequest = db.newresourcerequest.Single(x => x.resourcerequestid == id); //get the passed it details and binding it to model
Ramesh PalanivelRank #372 · 6.8K reputationPosted Apr 25, 2017, 9:39 PM EDT
Indu YadavRank #5,629 · 292 reputationPosted Apr 25, 2017, 9:50 PM EDT
Prasath Balakrishnan34 reputationPosted Apr 25, 2017, 10:03 PM EDT
Indu YadavRank #5,629 · 292 reputationPosted Apr 25, 2017, 10:11 PM EDT
Ramesh PalanivelRank #372 · 6.8K reputationPosted Apr 25, 2017, 10:14 PM EDT
Indu YadavRank #5,629 · 292 reputationPosted Apr 25, 2017, 10:40 PM EDT
Ramesh PalanivelRank #372 · 6.8K reputationPosted Apr 25, 2017, 10:58 PM EDT
Indu YadavRank #5,629 · 292 reputationPosted Apr 25, 2017, 11:13 PM EDT
Ramesh PalanivelRank #372 · 6.8K reputationPosted Apr 25, 2017, 11:23 PM EDT
Indu YadavRank #5,629 · 292 reputationPosted Apr 25, 2017, 11:28 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts