需要在MVC1中列出最佳方法

时间:2011-08-22 20:00:02

标签: asp.net-mvc

实施例: 我有员工帐户详细信息页面(视图),其中包含超过1个员工帐户。它包含近10个文本框和几个下拉框。我需要显示帐户列表。

所以在最重要的部分,我想给10个文本框和下拉列表以及一个名为“添加到列表”的按钮,下面我要显示带有编辑,删除链接的帐户列表。编辑应使用值再次填充所有文本框。用户可以进行更改并再次按“添加到列表”,值应该更改。我不需要排序,过滤......所以在想我是否可以只使用普通渲染,或者我需要任何网格小部件或其他............

此外,我的列表应该只显示3-4列,这是来自所有文本框和下拉列表的部分信息。所以我可能需要在会话或内存中有其他信息。不知道我怎么能在MVC中做到这一点

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<thead>
    <tr>
        <th width="13%"></th>
        <th width="12%"></th>
        <th width="13%"></th>
        <th width="12%"></th>
        <th width="13%"></th>
        <th width="12%"></th>
    </tr>
 </thead>
<tbody>
    <tr>
        <td colspan="6" class="comHead"><strong>Food Nutrition Information</strong></td>
    </tr>
    <tr>
        <td><label for="txtDefaultServingSize">Serving Size: *</label></td>
        <td colspan="5">
            <%=Html.TextBox("txtDefaultServingSize", String.Format("{0:0.000}", Model.NutritionInfos[0].ServingSizeWhole), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;
            <%=Html.DropDownList("ddlDefaultServingSizeFraction", Model.NutritionInfos[0].ServingSizeFraction)%>&nbsp;&nbsp;
            <%=Html.DropDownList("ddlServings", Model.NutritionInfos[0].ServingUnits, new{ @class = "dropdownlist" } ) %>&nbsp;&nbsp;
            <%=Html.ValidationMessage("FoodUnit", "*")%>
        </td>
    </tr>
    <tr>
        <td ><label for="txtCalories">Calories: *</label></td>
        <td>
            <%=Html.TextBox("txtCalories", String.Format("{0:0.000}", Model.NutritionInfos[0].Calories.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>
        </td>
        <td class="style1"><label for="txtCaloriesFromFat">Calories from Fat:</label></td>
        <td colspan="3">
            <%=Html.TextBox("txtCaloriesFromFat", String.Format("{0:0.000}", Model.NutritionInfos[0].CaloriesFromFat.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>
        </td>
    </tr>
    <tr>
        <td class="style1"><label for="txtTotalFat">Total Fat:</label></td>
        <td>
            <%=Html.TextBox("txtTotalFat", String.Format("{0:0.000}", Model.NutritionInfos[0].TotalFat.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;g
        </td>
        <td class="style1"><label for="txtSaturatedFat" class="">Saturated Fat:</label></td>
        <td>
            <%=Html.TextBox("txtSaturatedFat", String.Format("{0:0.000}", Model.NutritionInfos[0].SaturatedFat.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;g
        </td>
        <td class="style1"><label for="txtTransFat" class="">Trans Fat:</label></td>
        <td>
            <%=Html.TextBox("txtTransFat", String.Format("{0:0.000}", Model.NutritionInfos[0].TransFat.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;g
        </td>
    </tr>        
    <tr>
        <td class="style1"><label for="txtCholesterol">Cholesterol:</label></td>
        <td>
            <%=Html.TextBox("txtCholesterol", String.Format("{0:0.000}", Model.NutritionInfos[0].Cholesterol.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;mg
        </td>
        <td class="style1"><label for="txtSodium">Sodium:</label></td>
        <td colspan="3">
            <%=Html.TextBox("txtSodium", String.Format("{0:0.000}", Model.NutritionInfos[0].Sodium.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;mg
        </td>
    </tr>
    <tr>
        <td class="style1"><label for="txtTotalCarbohydrate">Total Carbohydrate:</label></td>
        <td>
            <%=Html.TextBox("txtTotalCarbohydrate", String.Format("{0:0.000}", Model.NutritionInfos[0].TotalCarbohydrates.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;g
        </td>
        <td class="style1"><label for="txtDietaryFiber" class="">Dietary Fiber:</label></td>
        <td>
            <%=Html.TextBox("txtDietaryFiber", String.Format("{0:0.000}", Model.NutritionInfos[0].DietaryFibers.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;g
        </td>
        <td class="style1"><label for="txtSugars" class="">Sugars:</label></td>
        <td>
            <%=Html.TextBox("txtSugars", String.Format("{0:0.000}", Model.NutritionInfos[0].Sugars.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;g
        </td>
    </tr>
    <tr>
        <td class="style1"><label for="txtProtein">Protein:</label></td>
        <td>
            <%=Html.TextBox("txtProtein", String.Format("{0:0.000}", Model.NutritionInfos[0].Protein.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;g
        </td>
        <td class="style1"><label for="txtVitaminA">Vitamin A:</label></td>
        <td>
            <%=Html.TextBox("txtVitaminA", String.Format("{0:0.000}", Model.NutritionInfos[0].VitaminA.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;IU
        </td>
        <td class="style1"><label for="txtVitaminC">Vitamin C:</label></td>
        <td>
            <%=Html.TextBox("txtVitaminC", String.Format("{0:0.000}", Model.NutritionInfos[0].VitaminC.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;mg
        </td>
    </tr>
    <tr>
        <td class="style1"><label for="txtCalcium">Calcium:</label></td>
        <td>
            <%=Html.TextBox("txtCalcium", String.Format("{0:0.000}", Model.NutritionInfos[0].Calcium.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;mg
        </td>
        <td class="style1"><label for="txtIron">Iron:</label></td>
        <td>
            <%=Html.TextBox("txtIron", String.Format("{0:0.000}", Model.NutritionInfos[0].Iron.NutritionValue.EmptyIfZero()), new { @maxlength = "8", @style = "width: 75px; text-align:right", onkeypress = "return utility.ui.blockNonNumbers(this, event, true, false);" })%>&nbsp;&nbsp;mg
        </td>
        <td>
            <%= Html.CheckBox("IsDefaultServing:", Model.NutritionInfos[0].IsDefaultServing) %><span>&nbsp;Default Serving?</span>
        </td>
    </tr>
    <tr>
        <td colspan="6" align="right"><input type="button" value="Add To List" id="btnAddToList"/></td>
    </tr>
</tbody> 

                          服务大小             单元             卡路里             Cal Fat             总脂肪             星期六脂肪             反式脂肪             Choles             钠             总碳水化合物                                                                                                                                                                                                                                                                          “onclick =”javascript:Alert('正在进行');“&gt;编辑                     “onclick =”javascript:提醒('进行中');“&gt;删除                                        
                             服务说明:

1 个答案:

答案 0 :(得分:0)

显示为具有部分视图的普通列表