0

私は更新ページを持っています。フィールド呼び出しの成分名があり、ドロップダウンにはすべての成分がリストされていますが、レシピの各成分に保存されている値をバインドするにはどうすればよいですか。

私のコントローラーには、ドロップダウンにすべての成分をリストする次のコードがあります。

foreach (RecipeIngredient recipeIngredient in recipe.RecipeIngredientList)
{
    rIngredients.Add(recipeIngredient);
}

更新ページで、テキスト ボックスに値を表示します。

4

1 に答える 1

0

<%: Html.DropDownList("BusinessTypeId", new SelectList(Model.BusinessTypes, "BusinessTypeId", "BusinessTypeName"), "Select an Option")%>

ここで、値は BusinessTypeId で、名前は BusinessTypeName です

 foreach (BusinessType businessType in _businessDetails.BusinessTypes)
                {

                        businessType.BusinessTypeName = businessType.SpanishBusinessTypeName;

                    businessTypeLst.Add(businessType);
                }

//ページ

var _ddValue = $('#BusinessTypeId').val();

テキストボックスに割り当てます

$('#txtboxId').val(_ddValue );

于 2012-04-05T08:40:41.907 に答える