Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.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# 在我的视图(visual studio.net)中对生成的表进行排序 Documenten 标题 描述 下载 * @foreach(模型、轨迹、组件中的var项) { if(item.getType()=“文档”) { @项目.标题 @项目.说明 } }_C#_Html_.net_Visual Studio_Html Table - Fatal编程技术网

C# 在我的视图(visual studio.net)中对生成的表进行排序 Documenten 标题 描述 下载 * @foreach(模型、轨迹、组件中的var项) { if(item.getType()=“文档”) { @项目.标题 @项目.说明 } }

C# 在我的视图(visual studio.net)中对生成的表进行排序 Documenten 标题 描述 下载 * @foreach(模型、轨迹、组件中的var项) { if(item.getType()=“文档”) { @项目.标题 @项目.说明 } },c#,html,.net,visual-studio,html-table,C#,Html,.net,Visual Studio,Html Table,现在,当我初始化视图时,按标题对该表排序的最佳方法是什么?我更喜欢在控制器中对其排序,但您可以执行以下操作: <h2>Documenten</h2> <table border="1""> <tr> <th"> title </th> <th> description </t

现在,当我初始化视图时,按标题对该表排序的最佳方法是什么?

我更喜欢在控制器中对其排序,但您可以执行以下操作:

 <h2>Documenten</h2>
    <table border="1"">
     <tr>   
        <th">
           title
        </th>
        <th>
           description
        </th>
         <th>
             Download
         </th>
    </tr>*  



  @foreach (var item in Model.Trajects.Components)
    {

        if (item.getType() == "document")
        {

        <tr>
                 <td>

                     @item.Title
                 </td>
                 <td>
                     @item.Description
                 </td>
                 <td><a href='@Url.Action("Download","Component", new               {componentid=item.componentID,l=Request["trajectcode"],g = Model})'>
                        <img src='@Url.Content("../../Images/play.png")' alt="Home Page">
                    </a> </td>
        </tr>            
        } 

    }
    </table>
@foreach(Model.Trajects.Components.OrderBy(c=>c.Title)中的变量项)
{
if(item.getType()=“文档”)
{
@项目.标题
@项目.说明
} 
}

请参阅foreach语句中的
OrderBy

在初始化视图之前对数据进行排序如何?我不能,因为它是Component的子类。非常感谢!!!虽然没有那么简单,但一直在搜索javascripts,哈哈
@foreach (var item in Model.Trajects.Components.OrderBy(c => c.Title)) 
{
    if (item.getType() == "document")
    {
        <tr>
            <td>@item.Title</td>
            <td>@item.Description</td>
            <td>
                <a href='@Url.Action("Download","Component", new { componentid = item.componentID, l = Request["trajectcode"], g = Model })'>
                    <img src='@Url.Content("../../Images/play.png")' alt="Home Page">
                </a>
            </td>
        </tr>            
    } 
}