2011-05-06 4 views
1

안녕하세요, 다음 샘플 견본 스크립트가 필요합니다> 이제 이것을 확장하고 @foreach (Dnn.ReportResults() 행의 DataRow 행) 뒤에 if 문을 추가해야합니다. if 문 querystytring 값 푸 foo라는 이름을 가진 컬럼의 값과 같은 경우에이 TNE 행이 도움을 내가했습니다시작 프로그래머 용 Razor 도움말

+0

Request.QueryString을 경우에 [ "푸"] 내가 그것을 정상적인 C#을 asp.net 응용 프로그램에서 작동하도록 coudl 다양한 시도와 같은 것들에 대한 cially. 나는 내가 면도기 설치에서 그것을 볼 필요가 있다고 생각한다. 나는 잘못 놓아야한다.} 또는 @ – nokiko

답변

3
<tbody> 
@foreach (DataRow row in Dnn.ReportResults().Rows) 
{ 
    if(Request.QueryString["foo"] == "bar") 
    { 
     <tr> 
     @foreach (var value in row.ItemArray) 
     { 
      <td>@value</td> 
     } 
     </tr> 
    } 
} 
</tbody> 

에 대한

<table> 
<thead> 
@{var table = Dnn.ReportResults();} 
<tr> 
@foreach (DataColumn col in table.Columns) 
{ 
<th>@col.ColumnName</th> 
} 
</tr> 
</thead> 
<tbody> 
@foreach (DataRow row in Dnn.ReportResults().Rows) 
{ 
<tr> 
@foreach (var value in row.ItemArray) 
{ 
<td>@value</td> 
} 
</tr> 
} 
</tbody> 
</table> 

감사를 렌더링 할 수 있다는 올바른지 확인 면도기 구문 오류가 발생하면 생산되는 YSD가 대개 매우 유용하다는 것을 알았습니다. espe 너무 많은 @s

0
<table> 
    <thead> 
    @{var table = Dnn.ReportResults();} 
<tr> 
    @foreach (DataColumn col in table.Columns) 
    { <th>@col.ColumnName 
     </th> } 
</tr> 
</thead> 
<tbody> 
    @foreach (DataColumn col in table.columns) 
    { 
     if (col.ColumnNamn == Request.QueryString["foo"]) 
     { 
    foreach (DataRow row in Dnn.ReportResults().Rows) 
    { <tr> 
     @foreach (var value in row.ItemArray) 
     { <td>@value 
      </td> 
     } 
    </tr> 
    } 
     } 
    } 
</tbody> 

관련 문제