Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Radiobuttonlist

Posted on 2006-10-20
10
Medium Priority
?
211 Views
Last Modified: 2010-04-16
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
Comment
Question by:siddhuoops
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 

Author Comment

by:siddhuoops
ID: 17777348
I really need help. Could somebody help??
0
 
LVL 1

Accepted Solution

by:
pascalprob earned 2000 total points
ID: 17791789
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
 

Author Comment

by:siddhuoops
ID: 17796806
Thanks a lot. It worked out great.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:siddhuoops
ID: 17796876
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
 
LVL 1

Expert Comment

by:pascalprob
ID: 17797652
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
 

Author Comment

by:siddhuoops
ID: 17797759
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
 
LVL 1

Expert Comment

by:pascalprob
ID: 17798068
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
 

Author Comment

by:siddhuoops
ID: 17798103
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
 
LVL 1

Expert Comment

by:pascalprob
ID: 17798412
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
 

Author Comment

by:siddhuoops
ID: 17798526
That worked great. Thanks a lot expert.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question