首页 新闻 会员 周边 捐助

asp.net MVC 批量删除?

0
悬赏园豆:40 [已关闭问题]

<body>
    <p>
        <%= Html.ActionLink("添加", "Create") %>&nbsp;&nbsp;|&nbsp;&nbsp;
        <%= Html.ActionLink("编辑", "Edit") %>&nbsp;&nbsp;|&nbsp;&nbsp;
        <%= Html.ActionLink("删除", "DeleteList", new { x = Html.CheckBox("chBox") }, new { onclick = "return confirm('你确定要删除该栏目?')" })%>
    </p>
    <table>
        <tr>
            <th>
                <input id="Checkbox1" type="checkbox" onclick="selectAll(this)" />
            </th>
            <th>
                类别编号
            </th>
            <th>
                父类ID
            </th>
            <th>
                类别名称
            </th>
            <th>
                备注
            </th>
            <th>
                添加人
            </th>
            <th>
                添加时间
            </th>
        </tr>

    <% foreach (var item in Model) { %>
   
        <tr>
            <td>
                <input name='chBox' type="checkbox" value="<%=item.NC_ID%>" />
            </td>
            <td>
                <%= Html.Encode(item.NC_ID) %>
            </td>
            <td>
                <%= Html.Encode(item.NC_ClassParentID) %>
            </td>
            <td>
                <%= Html.Encode(item.NC_Name) %>
            </td>
            <td>
                <%= Html.Encode(item.NC_Remark) %>
            </td>
            <td>
                <%= Html.Encode(item.NC_Uname) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:d}", item.NC_Time)) %>
            </td>
            <td>
                <%= Html.Encode(item.NC1) %>
            </td>
            <td>
                <%= Html.ActionLink("编辑", "Edit", new { id=item.NC_ID }) %> |
                <%= Html.ActionLink("详细信息", "Details", new { id=item.NC_ID })%> |
               <%-- <%= Html.ActionLink("删除", "Delete", new { id=item.NC_ID },--%>
                <%= Html.ActionLink("删除", "Delete", new { id = item.NC_ID }, new { onclick = "return confirm('你确定要删除该随笔?')" })%>
            </td>
        </tr>
   
    <% } %>


    </table>
</body>

 

 

后台代码:

public ActionResult DeleteList(string[] x)
        {

            for (int i = 0; i <= x.Length; i++)
            {
                WB_News_Class news = NewsClass.GetDinner(Convert.ToInt32(x[i]));
                if (news == null)
                    return View();
                else
                {
                    NewsClass.Delete(news);
                    NewsClass.Save();
                    return RedirectToAction("Index");
                }
            }
            return View();
        }

那位能给说下啊!或着给介绍一种解决方法!

duo的主页 duo | 初学一级 | 园豆:88
提问于:2009-11-11 14:47
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册