Design Problem

J

JRB

Hi, I'm a programmer, but new to ASP.NET. I'm playing around with the
Repeater and DataGrid controls. Here's the situation. I've got a MySQL
database containing a couple tables. One called "games", one called "picks".
picks has fields "GameID", and "PickedTeam". games has fields "GameID",
"HomeTeam", and "AwayTeam". I what to be able to display all the data in the
games database in a table on a webpage with the user being able to select who
he or she thinks will win that game. I want to use radio buttons so the user
can only choose one team per row. Then when the user has choosen a winner for
each game (or row) he or she clicks the "Sumbit" button. What needs to happen
now is that for each row, an entry is entered into the picks table. The
GameID and PickedTeam are entered. I'm not going to worry about any of the
validation yet until I have this working. The idea I have in my head is to
have a RadioButtonList for each row. The ID will be the GameID field pulled
from the database. Each RadioButton in the list's name will just be the name
of the team pulled from the database. Then when one team is choosen from each
row, what can be entered in the picks database is a bunch of rows based on
the name of the RadioButtonList and the value choosen in that List. This is
probably not a difficult problem for someone who really knows the controls
well and knows how to use them. Any feedback is really appreciated. Thanks!
 
J

Jeff Bowman

Here, give this a read for your RadioButtonList TemplateColumns:

http://aspnet.4guysfromrolla.com/articles/061002-1.aspx

Then, in the Click event of your submit button, you can iterate through your
DataGrid's Items collection. Each item (row) has a Cells collection, and each of
those in turn has a Controls collection.

Find out the index of your RadioButtonList in that Controls collection, and the
rest should be easy.

' Careful, not tested -- written from memory only
For Each loItem As DataGridItem In grdDataGrid.Items
For Each loCell As TableCell In loItem
For liIndex As Integer = 0 To loCell.Controls.Count - 1
If TypeOf loCell.Controls(liIndex) Is RadioButtonList Then
Response.Write(liIndex)
End For
End For
End For

HTH,
Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top