Hi Guys,
Can any one please tell me how to pass the data-bind text and value. i need to assign the value which was selected from the dropdownlist and need to bind to my Knockout.js model
Thanks In advance
What I have tried:
Sample Code:
C# code
XYZDataAccess objState = new XYZDataAccess();
List<SelectListItem> objSelectList = new List<SelectListItem>();
List<state> allStates = objState.GetAllStates(out errorCode);
foreach (State objSt in allStates)
{
SelectListItem objitem = new SelectListItem();
objitem.Text = objSt.Abbreviation;
objitem.Value = objSt.Abbreviation;
objSelectList.Add(objitem);
}
ViewBag.AllStatesList = objSelectList;
abc.cshtml
data-bind="text:" style="display:none">
@Html.DropDownList("State", (IList<SelectListItem>)ViewBag.AllStatesList, "", new { data_bind = " value: ", @style = "height:23px; width:41px;border: 1px #999;border-radius:5px" });