Question for each loop with radio button list


Active member
Sep 16, 2020
Programming Experience
I am having trouble with the for each loop
I need it to print into my label saying how many courses when I add courses to a radio button list. Any idea on how to fix this or make it execute? needs to be in a for each loop. Also if anyone has any notes on theses loops that would be great! Thank you!

These are the instructions from my professor:
When the user clicks on the Add a New Course LinkButton, a panel should appear to the right of the course summary. This panel should have a different color background and include the options needed to add a course to the RadioButtonList: a Course Prefix (required), a Course Number (required), and a Grade Earned (required DropDownList that contains the letter grade as the Text and the weight as the Value - weights can be found here:

If I can get help figuring out the number of courses I should easily be able to get the number of credits part.
I have not worked on the GPA yet. I'm doing that last since I still need to get an idea of how to start it.

Number of courses:
//make radio button list execute to labels under summary

// create variables for number of classes for a total
int intCurrent = 0;
int intCourseTotal = 0;

//add all course together for Number of Courses
foreach (ListItem liNumber in rblCourseHistory.Items)
    intCurrent = Convert.ToInt32(rblCourseHistory.Text);
    intCourseTotal += intCurrent;
Last edited by a moderator:


C# Forum Moderator
Staff member
Apr 23, 2011
Sydney, Australia
Programming Experience
I don't really understand what you're asking. If you're saying that you want to display the number of courses in a Label then surely that means just assigning the Items.Count of the RadioButtonList to the Text of the Label. I have no idea what that loop is supposed to be accomplishing.
Top Bottom