开发者

MVC Html.CheckBox list and Jquery Post

my code is

 <% using (Html.BeginForm())
       {%>
    <table>
        <tr>

            <th>
                LabelID_FK
            </th>
            <th>
                LabelName
            </th>
            <th>
                LabelIsDocum开发者_高级运维ent
            </th>
        </tr>
        <% foreach (var item in Model)
           { %>
        <tr>

            <td>
                <%: item.LabelID_FK %>
            </td>
            <td>
                <%: item.LabelName %>
            </td>
            <td>
              <%--  <input type="checkbox" value="df" id="chk" onclick="check()" />--%>
                <%=Html.CheckBox("chk_"+ item.LabelID_FK)%>
            </td>
        </tr>
        <% } %>
    </table>
    <p>
        <input type="button" value="submit" id="btn" />
    </p>

which show checkbox list for document label which user can select it . i want pass data list which user select checkbox it use jquery post what i do?


i use this code when user click on button and work very good

[HttpPost]
        public ActionResult DocumentLabel(FormCollection model)
        {


            for (int i = 0; i < model.Count; i++)
            {
                AriaCRMEntities aria = new AriaCRMEntities();
                DocumentLabel label = new DocumentLabel();
                string lbl = model[i].ToString();
                string[] check = lbl.Split(',');

                bool chk = Convert.ToBoolean(check[0]);

                string name = model.Keys[i].ToString();
                string[] n = name.Split('_');
                string lblid = n[1];

                if (chk)
                {
                    label.LabelID_FK = Int32.Parse(lblid);
                    Guid id = Guid.NewGuid();
                    label.DocumentID_FK = id;

                    aria.DocumentLabels.AddObject(label);
                    aria.SaveChanges();
                }

            }


            return Content("0ok");
        }

but i want jquery post i need array check box whit select it to pass it to controller?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜