S
stormystormy
Hallo
Hoffe es kann mir wer helfen
Ich möchte ein Datagrid das das Paging unterstützt
Weiters sollte aber auch in einer Spalte ein Link sein (wird ein Popup aufgerufen)
Soweit habe ich das ja schon
Aber das Problem wenn ich dann auf den Link klick dann geht das Grid wieder auf Seite1 (sollte aber auf der aktuellen bleiben)
Hoffe dass das zusammen funktioniert (sollte auch noch eine manuelle Sortierung zulassen) aber wie und ob das ist die Frage
Es muss doch irgendwo was mit
e As DataGridCommandEventArgs &
e As DataGridPageChangedEventArgs
zutun haben aber wie bekomm ich das alles auf einmal
Hier der Code
Danke schon mal
Roland
<%@ Import Namespace="System.Data" %>
<HTML>
<script language="VB" runat="server">
Dim startIndex As Integer
Public Test
Function CreateDataSource() As ICollection
Dim dt As DataTable
Dim dr As DataRow
Dim i As Integer
'create a DataTable
dt = New DataTable
dt.Columns.Add(New DataColumn("IntegerValue", GetType(Integer)))
dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn("DateTimeValue", GetType(String)))
dt.Columns.Add(New DataColumn("BoolValue", GetType(Boolean)))
' "query" should return one page of data, beginning at the start index
For i = startIndex to (startIndex + MyDataGrid.PageSize)
dr = dt.NewRow()
dr(0) = i
dr(1) = "Element " + i.ToString()
dr(2) = DateTime.Now.ToShortDateString
If (i Mod 2 <> 0) Then
dr(3) = True
Else
dr(3) = False
End If
dt.Rows.Add(dr)
Next
'return a DataView to the DataTable
CreateDataSource = New DataView(dt)
End Function
Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
startIndex = 0
MyDataGrid.VirtualItemCount = 200
End If
BindGrid
End Sub
Sub MyDataGrid_Page(sender As Object, e As DataGridPageChangedEventArgs)
startIndex = e.NewPageIndex * MyDataGrid.PageSize
MyDataGrid.CurrentPageIndex = e.NewPageIndex
response.write(e.NewPageIndex)
BindGrid
End Sub
Sub BindGrid()
MyDataGrid.DataSource = CreateDataSource()
MyDataGrid.DataBind
End Sub
Sub Grid_CartCommand(sender As Object, e As DataGridCommandEventArgs)
End Sub
</script>
<body>
<form runat="server" ID="Form1">
<ASP
ataGrid id="MyDataGrid" runat="server" AllowPaging="True" AllowCustomPaging="True" PageSize="10" PagerStyle-Mode="NumericPages" PagerStyle-HorizontalAlign="Right" OnPageIndexChanged="MyDataGrid_Page" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee" AutoGenerateColumns="false" OnItemCommand="Grid_CartCommand"
>
<Columns>
<asp:ButtonColumn HeaderText="Message" text="View" CommandName="ViewMessage" />
<asp:BoundColumn HeaderText="IntegerValue" DataField="IntegerValue" />
<asp:BoundColumn HeaderText="IStringValue" DataField="IntegerValue" />
<asp:BoundColumn HeaderText="DateTimeValue" DataField="DateTimeValue" />
<asp:BoundColumn HeaderText="BoolValue" DataField="BoolValue" />
</Columns>
</ASP
ataGrid>
</form>
</body>
</HTML>
Hoffe es kann mir wer helfen
Ich möchte ein Datagrid das das Paging unterstützt
Weiters sollte aber auch in einer Spalte ein Link sein (wird ein Popup aufgerufen)
Soweit habe ich das ja schon
Aber das Problem wenn ich dann auf den Link klick dann geht das Grid wieder auf Seite1 (sollte aber auf der aktuellen bleiben)
Hoffe dass das zusammen funktioniert (sollte auch noch eine manuelle Sortierung zulassen) aber wie und ob das ist die Frage
Es muss doch irgendwo was mit
e As DataGridCommandEventArgs &
e As DataGridPageChangedEventArgs
zutun haben aber wie bekomm ich das alles auf einmal
Hier der Code
Danke schon mal
Roland
<%@ Import Namespace="System.Data" %>
<HTML>
<script language="VB" runat="server">
Dim startIndex As Integer
Public Test
Function CreateDataSource() As ICollection
Dim dt As DataTable
Dim dr As DataRow
Dim i As Integer
'create a DataTable
dt = New DataTable
dt.Columns.Add(New DataColumn("IntegerValue", GetType(Integer)))
dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn("DateTimeValue", GetType(String)))
dt.Columns.Add(New DataColumn("BoolValue", GetType(Boolean)))
' "query" should return one page of data, beginning at the start index
For i = startIndex to (startIndex + MyDataGrid.PageSize)
dr = dt.NewRow()
dr(0) = i
dr(1) = "Element " + i.ToString()
dr(2) = DateTime.Now.ToShortDateString
If (i Mod 2 <> 0) Then
dr(3) = True
Else
dr(3) = False
End If
dt.Rows.Add(dr)
Next
'return a DataView to the DataTable
CreateDataSource = New DataView(dt)
End Function
Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
startIndex = 0
MyDataGrid.VirtualItemCount = 200
End If
BindGrid
End Sub
Sub MyDataGrid_Page(sender As Object, e As DataGridPageChangedEventArgs)
startIndex = e.NewPageIndex * MyDataGrid.PageSize
MyDataGrid.CurrentPageIndex = e.NewPageIndex
response.write(e.NewPageIndex)
BindGrid
End Sub
Sub BindGrid()
MyDataGrid.DataSource = CreateDataSource()
MyDataGrid.DataBind
End Sub
Sub Grid_CartCommand(sender As Object, e As DataGridCommandEventArgs)
End Sub
</script>
<body>
<form runat="server" ID="Form1">
<ASP

>
<Columns>
<asp:ButtonColumn HeaderText="Message" text="View" CommandName="ViewMessage" />
<asp:BoundColumn HeaderText="IntegerValue" DataField="IntegerValue" />
<asp:BoundColumn HeaderText="IStringValue" DataField="IntegerValue" />
<asp:BoundColumn HeaderText="DateTimeValue" DataField="DateTimeValue" />
<asp:BoundColumn HeaderText="BoolValue" DataField="BoolValue" />
</Columns>
</ASP

</form>
</body>
</HTML>