Nu har jag prövat d mesta men utan resultat vänder jag nu mig till er här...
<%@ Page Language="VB" %>
<%@ Import Namespace="System.data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
Sub Page_Load(sender as object, e as eventargs)
If Not Page.IsPostBack Then
BindGrid
End If
End Sub
Sub BindGrid
Dim objForum as new Guardian.Show
Dim objReader = objForum.VisaAllt
dlItems.DataSource = objReader
dlItems.Databind()
objReader.Close
End Sub
Sub Changed(obj as Object, e as DataGridPageChangedeventargs)
dlItems.CurrentPageIndex = e.NewPageIndex
dlItems.Databind()
End Sub
</script>
<html><body>
<form runat="server">
<asp:DataGrid id="dlItems" runat="server"
BorderColor="black"
GridLines="vertical"
Cellpadding="4"
Cellspacing="0"
Width="450"
Font-Names="Arial"
Font-Size="8pt"
ShowFooter="true"
HeaderStyle-BackColor="#cccc99"
FooterStyle-BackColor="#cccc99"
ItemStyle-BackColor="#ffffff"
AlternatingItemStyle-BackColor="#cccccc"
AutoGenerateColumns="False"
AllowCustomPaging="true"
PageSize=1
PagerStyle-Mode = NumericPages
PagerStyle-PageButtonCount = 2
OnPageIndexChanged="Changed">
<Columns>
<asp:TemplateColumn HeaderText="Avsändare">
<ItemTemplate>
<asp:Label id="Avsändare" runat="server" Text='<%# Container.DataItem("Author") %>' />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Meddelande" DataField="Message" />
<asp:BoundColumn HeaderText="Tid" DataField="Date" />
</Columns>
</asp:DataGrid>
</form>
</body></html>
Alla tips mottages gärna, även förslag på optimering...
Cannot compute Count for a data source that does not implement ICollection.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Cannot compute Count for a data source that does not implement ICollection.
Source Error:
Line 14: Dim objReader = objForum.VisaAllt
Line 15: dlItems.DataSource = objReader
Line 16: dlItems.Databind()
Line 17: objReader.Close
Line 18: End Sub