• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

Radiobuttonlist

Hi there,

      I have the following program to do and I have no idea. I hope I will get some help.
The client will follow the survey and based on what they select, they will get points and the points are laid out as follows:


Answers:               ROP   FSI    Cable   BTV    Radio    Direct Mail

Lead Gen               4         4         1        1         3                4

New Cust               3         3         3        3         3                3

For, eg if they select lead gen, they will get the scores for ROP, FSI, Cable, BTV, Radio and Direct Mail. There are 11 questions and at the end, the scores will add like this:

Answers:               ROP   FSI    Cable   BTV    Radio    Direct Mail

Lead Gen               4         4         1        1         3                4

New Cust               3         3         3        3         3                3

…….

…….

Total                     Total   Total    Total   Total    Total          Total

based on the total they will get two suggestions to go, the highest total followed by the second highest.

I hope this makes clear.

Thank you all in advance.

 





0
siddhuoops
Asked:
siddhuoops
  • 6
  • 4
1 Solution
 
siddhuoopsAuthor Commented:
I really need help. Could somebody help??
0
 
pascalprobCommented:
I am assuming you are attempting a web-based solution, and as your topic suggests, you are planning on using a radiobuttonlist.
You will need a seperate radiobuttonlist for each question.

Initialize a variable for each of your "columns". (One for ROP, one for RSI etc);

When the user clicks submit, set a variable with the selected item's value property. The value property will simply be a list of the points for each column. Then add the points for each column to the variable for each column, as I've shown below. If you have any questions, feel free to ask. This will work as long as the points you can gain for each column per question are smaller than or equal to 9 - in other words, no double figures.

<%@ Page Language="C#" %>
<script runat="server">

    int var1 = 0; // column1 eg: ROP
    int var2 = 0; // column 2 eg: FSI
    int var3 = 0; // column 3 eg: Cable
   
    void Button1_Click(object sender, EventArgs e) // Submit button click
    {
        string q1AllCols = RadioButtonList1.SelectedItem.Value; // This will be set to "156" OR "213" OR "355"
        string q2AllCols = RadioButtonList2.SelectedItem.Value; // This will be set to "472" OR "590" OR "627"
   
        var1 += int.Parse(q1AllCols[0].ToString());
        var1 += int.Parse(q2AllCols[0].ToString());
   
        var2 += int.Parse(q1AllCols[1].ToString());
        var2 += int.Parse(q2AllCols[1].ToString());
   
        var3 += int.Parse(q1AllCols[2].ToString());
        var3 += int.Parse(q2AllCols[2].ToString());
   
        Label1.Text = "Col 1 adds to: " + var1;
        Label2.Text = "Col 2 adds to: " + var2;
        Label3.Text = "Col 3 adds to: " + var3;
    }

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <asp:RadioButtonList id="RadioButtonList1" runat="server">
            <asp:ListItem Value="156">Always</asp:ListItem>
            <asp:ListItem Value="213">Sometimes</asp:ListItem>
            <asp:ListItem Value="355">Never</asp:ListItem>
        </asp:RadioButtonList>
        <br />
        <br />
        <asp:RadioButtonList id="RadioButtonList2" runat="server">
            <asp:ListItem Value="473">Always</asp:ListItem>
            <asp:ListItem Value="590">Sometimes</asp:ListItem>
            <asp:ListItem Value="627">Never</asp:ListItem>
        </asp:RadioButtonList>
        <br />
        <br />
        <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Submit"></asp:Button>
        <br />
        <br />
        <asp:Label id="Label1" runat="server"></asp:Label>
        <br />
        <asp:Label id="Label2" runat="server"></asp:Label>
        <br />
        <asp:Label id="Label3" runat="server"></asp:Label>
    </form>
</body>
</html>


0
 
siddhuoopsAuthor Commented:
Thanks a lot. It worked out great.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
siddhuoopsAuthor Commented:
Ok! now I have to do this. Once, I have the total for each column, on the next page I have to display just the two totals depending which column got the highest followed by the second highest. For eg. if ROP = 36, FSI=45, Cable=25, BTV=29, Radio=28 and Direct Mail=40 then I would have to show or in other words give the client a recommendation to use just the two options. In this case, FSI has the highest point followed by the Direct Mail. Then, the last page would say "based on your campaign objectives, we would recommend the following in the order they appear:
1) FSI
2) Direct Mail

Let me know if you didn't understand what I really want.
0
 
pascalprobCommented:
Pleasure.

For your second question you will need to put all your column values into an array, and then you can simply sort the array.
See the following code:

int[] cols = {col1Var, col2Var, col3Var, col4Var, col5Var, col6Var};
Array.Sort(cols);

someLabel.Text = "Highest points: " + cols[0];
someLabel2.Text = "Second highest points: " + cols[1];
0
 
siddhuoopsAuthor Commented:
I tried doing it but instead of giving me FSI and Direct Mail since those have the highest point, it gave me the ones that are lowest. For example, in this case, it would be Cable and BTV. Please look at the post above to see what I have assigned the values for all six options.
0
 
pascalprobCommented:
That is odd. Either way, the array has 6 possible index values, from 0 to 5. If you're finding the lowest values at index 0 and 1, you'll find the highest at index 5 and 4, once you've done the sort. :)

someLabel.Text = "Highest points: " + cols[5];
someLabel2.Text = "Second highest points: " + cols[4];
0
 
siddhuoopsAuthor Commented:
Hi pascalprob, I modified your above code and was able to get the points for the highest and the second highest. Since, in my case there are 5 columns, so I changed this code to;

someLabel.Text = "Highest points: " + cols[5];
someLabel2.Text = "Second highest points: " + cols[4];

This would give me the highest point followed by the second highest. But instead of showing the points, I want to show them the actual column name. If FSI= 45, the highest and Cable=40 the second highest, then the result would be
1) FSI
2)Cable

How should I do this?

Thank You in advance.
0
 
pascalprobCommented:
What you need to do is compare the highest and second highest values (45 and 40 as per your example) to each of your column variables.
The most effective way to do this would be to use loops, but for simplicity's sake I will show you how to do it with if statements:

int first = cols[5];
int second = cols[4];

if (first == col1Var)
{
    someLabel.Text = "1) ROP";
}
else if (first == col2Var)
{
    someLabel.Text = "1) FSI";
}
.
. // repeat as necessary
.
else
{
    someLabel.Text = "1) Direct Mail"; // for your last column you don't need to compare the variables - if it's not equal to col1, 2, 3, 4 or 5 then it must be 6
}

Repeat all of the above for the "second" variable.
0
 
siddhuoopsAuthor Commented:
That worked great. Thanks a lot expert.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now