基于gridview数据的数据评分系统
我想做的基本上是有一个对用户进行排名的列,因此如果有 10 人,它将对销售额最高的人进行排名 10,对第二高的人进行排名 9,依此类推。并不总是有 10 名员工
,我使用存储过程和 sqldatasource 连接到我的存储过程。 为了获取每个代理商的所有数据,然后我使用诸如
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
获取运行总计之
类的函数,我可以做类似的事情
Dim salesrank As Decimal = 0.0
Function Getsalesrank(ByVal salestorank As Decimal) As Decimal
Dim rank As New ArrayList
rank.Add(salestorank)
End Function
,然后如何对数组列表进行排序并打印代理商销售总额的索引?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您使用的是 .Net 2.0 并且显然不反对使用内置类来完成数据调用,因此我建议您从使用 SQLDataSource 切换到强类型数据集(.xsd 文件)。您可以创建类型化的 DataTable 和 TableAdapter,它们将执行初始查询并生成集合对象(表),这些对象可以在您对其执行其他操作时保存所需的数据。创建数据集后,您可以通过以下方式简单地调用它:
如果您创建 DataTable,使其包含一个名为
TotalSales
的空列(我假设数据表包含由用户索引的数据),您可以使用总销售额方法填充该列。一旦您按用户组织了表格,您就可以使用表格的 DefaultView 进行排序并绑定到您的 GridView:完成此操作后,您可以操作 GridView 的一列来显示数字排名。这将在
RowDataBound
事件中完成。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
RowDataBound
event.