나는 체크 박스 페이지를 가지고 있는데 그 중 몇 개를 선택하고 제출을 클릭 한 다음 두 번째 페이지로 이동합니다. 이 페이지에는 이전 페이지에서 선택한 확인란을 사용하여 작성한 listview가 있습니다. 이제이 목록 뷰에 정렬 가능성을 어떻게 추가 할 수 있는지 궁금합니다.레이아웃 뷰가 레이아웃 템플릿을 포함하지 않고 코드 숨김으로 포함되어 있지 않을 때 정렬 가능하게 만들기
이전에는 CommandName = 'sort'CommandArgument = 'column'을 LayoutTemplate의 머리글 링크에 추가했습니다. 그러나 내 listview는 listview 외부의 머리글 행이므로 작동하지 않는 것 같습니다. 이 구현할 수있는 방법에 대한 아이디어? 이것은 내가 지금까지 무엇을 가지고 : 뒤에 코드에서 다음
<!-- header row (outside of listview, when I try to put it as a LayoutTemplate in listview i get an error, see below) -->
<table>
<tr><% For Each i As String In Request.Form
If i.IndexOf("checkbox_") = 0 Then
Response.Write("<th>" & i.Substring(Len("checkbox_")) & "</th>")
End If
Next %></tr>
</table>
<!-- Then the listview: -->
<asp:ListView runat="server" ID="ReportListView" DataSourceID="ReportListViewSDS">
<ItemTemplate>
<table>
<tr>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
</tr>
</table>
</ItemTemplate>
</asp:ListView>
: 나는 목록보기에 templatelayout를 추가하려고했습니다
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' This works fine:
' Get the Request Vars that are checkboxes, and build the sql command.
' Run the sql command
' Databind()
End Sub
' while binding the data, build the itemPlaceholder, to contain the contents of what's returned in the sql:
Protected Sub ReportListView_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles ReportListView.ItemDataBound
If (e.Item.ItemType = ListViewItemType.DataItem) Then
Dim plc As PlaceHolder = DirectCast(e.Item.FindControl("itemPlaceHolder"), PlaceHolder)
Dim di As Data.DataRowView = e.Item.DataItem()
For Each c In di.Row.ItemArray
Dim l As New Literal
l.Text = String.Format("<td class='customreport'>{0}</td>", c.ToString)
plc.Controls.Add(l)
Next
End If
End Sub
, 그러나 그것은 나에게 라인에 오류가 제공하는 데이터 (listview.databind()) 바인딩,이 가능하지 않기 때문에 가정합니다.
이 목록보기에서 정렬 가능한 헤더 행을 가져 오는 방법은 없나요? 미리 감사드립니다. 새내기, 미안해.
예, 시도했지만 해결할 수 없었습니다. 어쩌면 실제 예제가 있습니까, 아니면 더 자세합니까? 페이지를 확인하고 코드를 정확하게 구현하려고했습니다. 문제는 정렬해야하는 linkbutton을 클릭 할 때 페이지가 새로 고침되고 정렬이 적용되지 않는 경우입니다. 어떤 아이디어? 감사! – russds
문제는 Linkbuttons가 Listview 내에 없다는 것입니다. "CommandName"= Sort를리스트 뷰 외부에있는 링크 버튼에 추가하기 때문에 효과가없는 것 같습니다. 다시 말하지만, LayoutTemplate이 없다는 사실이 다시 돌아옵니다. 이후 나는 방금 내 헤더 테이블의 역할을 listview 외부의 테이블을 만들었습니다. – russds