What I want to do is basically have a column that ranks the users so if there were 10 people it would rank the person with the highest sales 10 and the second highest 9 and so on. Theres not always going to be 10 employees
I am using a stored procedure along with a sqldatasource to connect to my stored procedure.
To get all the data for each agent, then I am using functions like
Dim TotalSales As Decimal = 0.0
Function GetTotalSales(ByVal Price As Decimal) As Decimal
TotalSales += Price
Return Price
End Function
Function GetTotal() As Decimal
Return TotalSales
End Function
Dim TotalCalls As Decimal = 0.0
Function GetCalls(ByVal calls As Decimal) As Decimal
TotalCalls += calls
Return calls
End Function
Function GetTotalCalls() As Decimal
Return TotalCalls
End Function
to get running totals
could i do something like
Dim salesrank As Decimal = 0.0
Function Getsalesrank(ByVal salestorank As Decimal) As Decimal
Dim rank As New ArrayList
rank.Add(salestorank)
End Function
and then some how sort the array list and print the index of the agents sales total?
Since you’re using .Net 2.0 and apparently not adverse to using the built-in classes to accomplish data calls, I would recommend you switch from using the SQLDataSource to a strongly typed DataSet (.xsd file). You can create a typed DataTable and TableAdapter that will perform your initial queries and produce collection objects (tables) that can hold the data you need while you do other things to it. Once you have your dataset created you can call it simply by:
If you create your DataTable so that it holds an empty column called
TotalSales(I’m assuming the data table is holding data indexed by users), you can populate that column using your total sales method. Once you have the table organized by user you can use the table’s DefaultView to sort and bind to your GridView:When this is done you can manipulate one of the columns of your GridView to display the numeric ranking. This would be done in the
RowDataBoundevent.