[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


RadioButtonList - need horizontal instead of vertical

Posted on 2005-05-11
Medium Priority
Last Modified: 2009-07-29
This code makes the radio button list go down instead of across.
I fill the RBList from a data table - it's like a multiple question survey where the user selects from 1 to 10 as an answer by clicking corresponding RB.  Where do I make it go across the page?

      Row = addRow(CustomTable, null);
      addCell(Row, tdclass);
      addLabel(Row.Cells[1], Heading);
      addCell(Row, tdclass);

         if (strSelectionsSourceTable != "")
            addRadioButtons(Row.Cells[2], strSelectionsSourceTable, strParmValue, id);

      private void addRadioButtons(TableCell oCell, string strSelectionsSourceTable, string strParmValue, string ID)
            RadioButtonList vList = buildListForV(strSelectionsSourceTable, strParmValue);
            vList.ID = ID;

      private RadioButtonList buildListForV(string strSelectionsSourceTable, string strSelected)
            object [] dtVKRecords;
            DataTable dtVRecords;
            string sql = "SELECT * FROM " + strSelectionsSourceTable+" WHERE RecType='K1'";
            SqlConnection con = dbAccess.getSqlConnection("xxxxx");
            dtVKRecords = dbAccess.readFirstRecord(con, sql);
            dtVRecords = dbAccess.getDataTable(con, strSelectionsSourceTable, sql);

            string strPk    = null;
            string strPk2 = null;
            string strDesc1 = null;
            string strDesc2 = null;
            strPk = dtVKKey;
            strDesc1 = strPk;
            RadioButtonList result = new RadioButtonList();
            foreach (DataRow row in dtVRecords.Rows)
                  string sLabel = "";
                  sLabel = row[strDesc1].ToString();
                  ListItem newItem = new ListItem(sLabel, row[strPk].ToString());
                  sLabel = sLabel.Substring(0,50);
                  newItem = new ListItem(sLabel, row[strPk].ToString());
            return result;
Question by:dcass
  • 3

Expert Comment

ID: 13980490
you're are adding all radio button to one cell only, what problably is happening is that the table is not resizing in the way you want, instead of raising with of cell is raising height.

you can solve the problem by adding one radio button at a time to different cells in the same line.

Author Comment

ID: 13981650
I tried it but it didn't help.

Author Comment

ID: 13981827
I dont' think I did it right -

            result.Items.Add(newItem);      (from above)
            addCell(Row, tdclass);
                return result;

      private TableCell addCell(TableRow oRow, string cssClass)
                  TableCell newCell = new TableCell();
                  if (null != cssClass)
                        newCell.CssClass = cssClass;

                  return newCell;

Accepted Solution

dcass earned 0 total points
ID: 13982158
The answer was :
                  result.RepeatDirection = RepeatDirection.Horizontal;

Please close this.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month19 days, 13 hours left to enroll

873 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