Getting Started with .Net Leaderboard Project

I’m not a professional coder. I purchased the “Build Your Own ASP.NET Website” book a few years ago and created a website for my adventure racing business.

Now I would like to add a race Leaderboard, something like the one seen here http://race.findmespot.com/spot-racing-ui/pqleaderboard.jsp

I’ve been reading about DataSets, DataGrids, etc., but am not sure which one would get me closest to having a functioning leaderboard. Any opinions?


Some functions needed:

  • Sorted based on Number of checkpoints reached and then based on the time of day reached;

*Mouse over CPs to see when the team arrived;

*Color coded to reflect event type (mountain biking, trekking, etc.)


I keep thinking DataGrid, but I’m not sure that’s the best way.

Thanks,
Rodney

The control you want to use here is a GridView. GridView is basically a newer version of the DataGrid.

The being said, when it comes to binding, that is going to be up 2 you. SqlDataReader would be an option, I prefer not to use DataSets. But keep in mind that this is not going to be an easy task for a beginner.

I think it will be easier for you to go the OO route. Create an object(.cs class) for the grid with public properties exposed by getter and setter methods.

eg.

public string teamCountry {get;set;}
public string teamName {get;set;}
etc.

Then you would want a checkpoint object that holds all the info on a check point. eg. Img, stats, etc. Watever you need.

Then in your team object have a generic list of this object public List<CP> teamCheckpointList {get;set;}

Then you load a list of teams from the database, and then load all their checkpoints into the above object list. Then you just but a list of <Teams> to the gridview and use some javascript to make the popup and your done.

This is a very rough guide that will give you a good starting point. So the code is very half, half. So you shouldnt use it as is. I also used the shortcuts for get set, which is also not preferred. and you can write some custom getters to “lazy load” the objects.

But lots of research on this. And ask more specific questions when you get stuck, as this is a very broad question with a lot to it, and it is going to be impossible to help you out completely with this.

I hope this helps

Thanks, NightStalker,

I may need to farm this task out :slight_smile:

RS

Little help. I can’t figure out what is wrong with my syntax. I basically copied it from the ASP.Net book

My Error is:

Line 230:	intCPID = dgCheckpoints.DataKeys(e.Item.ItemIndex)
Line 231:	
Line 232:	strChek = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Line 233:	
Line 234:	strDate = CType(e.Item.Cells(4).Controls(0), TextBox).Text

I get it when I try to “Update” my DataGrid. Here is my Update coding:

Sub dg_Update(s As Object, e As DataGridCommandEventArgs)
	
	Dim intCPID As Integer
	Dim strChek, strDate As String
	Dim strCmd As String
	
	intCPID = dgCheckpoints.DataKeys(e.Item.ItemIndex)
	
	strChek = CType(e.Item.Cells(2).Controls(0), TextBox).Text
	
	strDate = CType(e.Item.Cells(4).Controls(0), TextBox).Text
	
	strCmd = "UPDATE tblCPReached SET Chek=@Chek, Date=@Date, Miss=@Miss WHERE CPID=@CPID"
	
	objCmd = New OleDbCommand(strCmd, objConn)
	objCmd.Parameters.Add("@Chek", strChek)
	objCmd.Parameters.Add("@Date", strDate)
	
	objCmd.Parameters.Add("@CPID", intCPID)
	
        objConn.Open()
        objCmd.ExecuteNonQuery()
        objConn.Close()
	
	dgCheckpoints.EditItemIndex = -1
	BindData2()
End Sub 

My Access database table “tblCPReached” has the following columns:

  • CPID – Primary Key
  • Race
  • Chek
  • Team
  • Date
  • Miss

Since I’m also having trouble adding the date and time to my record, I think it might have something to do with my “Date” in a Text string, but I’m not sure how else I should write it.

Thank you!

Ok, quick tip:

  • Do not use: objCmd.Parameters.Add(); instead, use this: objCmd.Parameters.AddWithValue();

What error are you getting, and on what line?

Could it be this line:
intCPID = dgCheckpoints.DataKeys(e.Item.ItemIndex)

Coz its been a while, but if memory serves that does not return and int.

You will need to get the value and convert that to and int. Cnt exactly remember how to do it now.

could be:
dgCheckpoints.DataKeys(e.Item.ItemIndex).Value

int.Parse(dgCheckpoints.DataKeys(e.Item.ItemIndex).Value);

That is if that is even the issue. And for further help after this problem has been resolved, it would be best to post them in separate threads.

Good luck hope this helps a bit

Thank you. I found one issue. I had a field called “Date” in the database and it didn’t like that. Changed it and it works fine.

Stay close to your computer, though! Just kidding :slight_smile: