Hej Skickar över tänkbara lösningar...AccessDataSource räkna poster
Kan man på något enkelt sätt få fram hur många poster som en AccessDataSoruce innehåller.
'Typ
minAccessSource.countRows
Jag vill slippa iterera igenom hela klabbet och räkna upp en räknare
vänligen
MagnusSv: AccessDataSource räkna poster
http://forums.asp.net/thread/1469692.aspx
eller
http://forums.asp.net/thread/1434785.aspx
Saxat ur http://msconline.maconstate.edu/tutorials/ASPNET2/ASPNET11/aspnet11-05.aspx
Missing Shopping Cart Items
It is possible, of course, that the customer arrives at the shopping cart page without having yet chosen items for purchase. In this case, an empty GridView is not displayed; rather, a message box is displayed indicating that no items appear in the shopping cart.
A determination needs to be made whether there are records in the ShopCart table for this customer. This information is given by the number of rows (records) returned by the AccessDataSource when it issues its SelectCommand. The data source's Selected event can be trapped by an OnSelected event handler to call a subprogram that checks the data source's AffectedRows property. If the number of rows returned by the AccessDataSource is 0, then the message box is displayed.
Notice that this OnSelected event handler appears in the AccessDataSource to call subprogram Get_Rows. Code for this subprogram is shown below.
Sub Get_Rows (Src As Object, Args As SqlDataSourceStatusEventArgs)
If Args.AffectedRows = 0 Then
NoItemsMessage.Visible = True
End If
End Sub
Listing 11-27. Get_Rows subprogram.
The subprogram argument for a data source's event handler is SqlDataSourceStatusEventArgs. This argument's AffectedRows property gives the number of rows returned when a SelectCommand is issued. In this example, if no rows are returned -- if this customer does not have any records in the ShopCart table -- the NoItemsMessage Label is made visible. The GridView is not visible since is has no rows to display.
Hoppas att det är användbart...
/Jesper