Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WebGrid需要按列筛选_C#_.net_Asp.net Mvc_Webgrid - Fatal编程技术网

C# WebGrid需要按列筛选

C# WebGrid需要按列筛选,c#,.net,asp.net-mvc,webgrid,C#,.net,Asp.net Mvc,Webgrid,这里我有一个WebGrid,我需要像Grid.Mvc中使用Filterable()的那样进行列过滤。请帮忙。谢谢 <div id="DivGrid"> @{ var grid = new WebGrid(source: Model, canPage: true, canSort: true, rowsPerPage: 10, defaultSort: "Employee ID"); grid.SortDirection = SortDirection.Descend

这里我有一个WebGrid,我需要像Grid.Mvc中使用Filterable()的那样进行列过滤。请帮忙。谢谢

 <div id="DivGrid">
@{
    var grid = new WebGrid(source: Model, canPage: true, canSort: true, rowsPerPage: 10, defaultSort: "Employee ID");
    grid.SortDirection = SortDirection.Descending;
    if (Model.Count() > 0)
    {
        <div class="moveRight"><strong> @ViewBag.SearchParameter</strong> | @grid.TotalRowCount @Html.Label("Record(s) found")</div>
        @grid.GetHtml(tableStyle: "PGrid", headerStyle: "Header", alternatingRowStyle: "altRow", htmlAttributes: new { id = "DataTable" }, columns: grid.Columns(
            grid.Column("Employee_ID", "Employee ID", format: @<text>  <span class="display-mode grid-filter-btn">@item.Employee_ID </span> <label id="EmployeeID" class="edit-mode grid-filter-btn">@item.Employee_ID</label> </text>, style: "col1Width", canSort:true),
            grid.Column("First_Name", "First Name", format: @<text>  <span class="display-mode"> <label id="lblFirstName">@item.First_Name</label> </span> <input type="text" id="FirstName" value="@item.First_Name" class="edit-mode" /></text>, style: "col2Width", canSort:true),
            grid.Column("Last_Name", "Last Name", format: @<text> <span class="display-mode"> <label id="lblLastName">@item.Last_Name</label> </span>  <input type="text" id="LastName" value="@item.Last_Name" class="edit-mode" /> </text>, style: "col2Width", canSort:true),
            grid.Column("Date_Of_Birth", "Date Of Birth", format: item => ((item.Date_Of_Birth == null) ? "" : item.Date_Of_Birth.ToString("MM/dd/yyyy")), style: "DateOfBirth"),
            //grid.Column("Date_Of_Birth", "Date Of Birth", format: item => ((item.Date_Of_Birth == null) ? "" : item.Date_Of_Birth.ToString("MM/dd/yyyy")) ),
            grid.Column(header: "Action", canSort: false, style: "action", format: @<text>                
            <button class="edit-user display-mode glyphicon glyphicon-edit"> Edit</button>
            <button class="display-mode delete-item glyphicon glyphicon-trash"> Delete</button>
            <button class="save-user edit-mode glyphicon glyphicon-save"> Save</button>
            <button class="cancel-user edit-mode glyphicon glyphicon-remove-sign"> Cancel</button></text>)));
    }
    else
    {
        <hr />@Html.Label("No, Record(s) not found")<<hr />
    }
}

@{
var grid=new WebGrid(来源:Model,canPage:true,canSort:true,rowsPerPage:10,defaultSort:Employee ID);
grid.SortDirection=SortDirection.Descending;
如果(Model.Count()>0)
{
@ViewBag.SearchParameter|@grid.TotalRowCount@Html.Label(“找到的记录”)
@GetHtml(tableStyle:“PGrid”,headerStyle:“Header”,alternatingRowStyle:“altRow”,htmlAttributes:new{id=“DataTable”},columns:grid.columns(
grid.Column(“Employee_ID”,“Employee ID”,格式:@@item.Employee_ID@item.Employee_ID,样式:“col1Width”,canSort:true),
grid.Column(“First_Name”,“First Name”,格式:@@item.First_Name,样式:“col2Width”,canSort:true),
grid.Column(“Last_Name”,“Last Name”,格式:@@item.Last_Name,样式:“col2Width”,canSort:true),
grid.Column(“出生日期”,“出生日期”,格式:item=>((item.Date\u Of\u Birth==null)?“”:item.Date\u Of\u Birth.ToString(“MM/dd/yyyyy”)),样式:“Dateof Birth”),
//grid.Column(“出生日期”,“出生日期”,格式:item=>((item.Date\u Of\u Birth==null)?“”:item.Date\u Of\u Birth.ToString(“MM/dd/yyyyy”),
grid.Column(标题:“Action”,canSort:false,样式:“Action”,格式:@
编辑
删除
拯救
取消);;
}
其他的
{


@Html.Label(“不,找不到记录”)据我所知,Asp.net MVC中没有用于筛选数据的内置选项。您需要编写自定义代码。请检查此链接

什么是按列筛选?是否只隐藏列?