Facebook

Friday, 27 July 2012

Mvc 3 Grid View With Check Box and delete button



    @model ModelName.EmailModel

@{
   var grid = new WebGrid(source: Model.getemail, rowsPerPage: 10, canPage: true, canSort: true);
}


@using (Html.BeginForm())
{
<div class="inner_div">
@grid.GetHtml(tableStyle: "grid", alternatingRowStyle: "alter_row", columns: grid.Columns(grid.Column("Email_Subscribe", "User Subscribe Email ID"), grid.Column(header:"Select All",format: @<text><input name="chkID" type="checkbox" value="@item.Email_Subscribe" /></text>), grid.Column(format: (item) => Html.ActionLink("Delete", "DeleteEmail", new { Email_ID = item.Email_ID }))))<br />
</div>    
@Html.EditorFor(model => model.message)<br />
<input type="submit" value="Send" />    <br /><br />
}
@using (Html.BeginForm("Email_FileUpload", "EmailSubscriber", FormMethod.Post, new { enctype = "multipart/form-data" }))
   {
   <input type="file" name="file" />
   <input type="submit" value="OK" />
   }
<script type="text/javascript">
   $(function () {
       addCheck();
   });
   function addCheck() {
       var $chk = $('<input/>').attr({ type: 'CheckBox', name: 'chkAll', id: 'chkAll', title: "Select All" });
       $('th:last').append($chk);
       $('#chkAll').click(function () {
           $(':checkbox').attr('checked', $(this).is(':checked') ? 'checked' : '');
       });
   }
</script>

No comments:

Post a Comment