ASP.NET - Number radio button in radio button list

Asked By Monu Nayak
08-Dec-11 12:49 AM
Hi,
Please any one tell me how to number radio button in radio button list when it is populated in asp.net.
i want to perform this operation

1. radiobutton1
2. radiobutton2
3. radiobutton3
4. radiobutton4

please help me on this.
  Suchit shah replied to Monu Nayak
08-Dec-11 12:54 AM
<asp:RadioButtonList id="radiolist1" runat="server">
<asp:ListItem selected="true">1. radiobutton1</asp:ListItem>
<asp:ListItem>2. radiobutton2</asp:ListItem>
<asp:ListItem>3. radiobutton3</asp:ListItem>
<asp:ListItem>4. radiobutton4</asp:ListItem>
</asp:RadioButtonList>

  Vickey F replied to Monu Nayak
08-Dec-11 12:54 AM
Try like this-

<asp:RadioButtonList id="ButtonList" runat="server"
  RepeatLayout="Flow"
  RepeatColumns="3"
  RepeatDirection="Horizontal">
  <asp:ListItem Text="1. radiobutton1"/>
  <asp:ListItem Text="2. radiobutton2"/>
  <asp:ListItem Text="3. radiobutton3"/>
  <asp:ListItem Text="4. radiobutton4"/>
</asp:RadioButtonList>
  dipa ahuja replied to Monu Nayak
08-Dec-11 01:46 AM
Try this way:

<asp:RadioButtonList ID="RadioButtonList1" runat="server">
  <asp:ListItem>C#</asp:ListItem>
  <asp:ListItem>ASP.NET</asp:ListItem>
</asp:RadioButtonList>

protected void Page_Load(object sender, EventArgs e)
{
  int i = 1;
  foreach (ListItem item in RadioButtonList1.Items)
  {
    item.Text = i.ToString() + ". " + item.Text;
    i++;
  }
}

  Monu Nayak replied to dipa ahuja
08-Dec-11 02:26 AM
Thanks dipa. But the code provided by you display radio button control first (radio button circle) and then numbers.
is it possible to displaying number first and then radio button control?

please do needful. here i am populating radio botton list at runtime.
  Monu Nayak replied to Suchit shah
08-Dec-11 02:26 AM
here i am populating radio button list at run time.
  Suchit shah replied to Monu Nayak
08-Dec-11 03:00 AM
Then use it one of the Following method to add it

Method - 1

radiolist1.Items.Add("1.radiobutton1");

radiolist1.Items.Add("2.radiobutton2");

radiolist1.Items.Add("3.radiobutton3");

radiolist1.Items.Add("4.radiobutton4");

Method - 2

for
(int i= 1 ; i<= 5; i++)

{

radiolist1.Items.Add(i + ".radiobutton" + i);

}

 

 

Create New Account
help
Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B A) What is scavenging? (B) What are different types of caching using cache object of ASP.NET? (B) How can you cache different version of same page using ASP.NET cache object? (A) How will implement Page Fragment Caching? (B) Can you compare ASP.NET sessions with classic ASP? (B) Which are
column. and how to get select for checkboxlist in editing. protected void Button4_Click( object sender, EventArgs e) { string SelectedItems = string .Empty; int i = 0; foreach ( ListItem item in CheckBoxList1.Items) { if (item.Selected) { if (i = = 1) { SelectedItems + = item.Text; } else { SelectedItems Insert query code } Hi Srikar, Try this code <asp:CheckBoxList runat = "server" ID = "test" > <asp:ListItem Text = "1" Value = "1" > < / asp:ListItem> <asp:ListItem Text = "2" Value = "2" > < / asp:ListItem> <asp:ListItem Text = "3" Value = "3" > < / asp:ListItem> <asp:ListItem Text = "3" Value = "3" > < / asp:ListItem> < / asp:CheckBoxList> foreach ( Item in test.Items
Answer Type" SortExpression = "AnswerType" > <EditItemTemplate> <asp:DropDownList ID = "DropDownList2" runat = "server" SelectedValue = ' <% # Bind("AnswerType") %> '> <asp:ListItem Value = "S" > Single Choice (radio button) < / asp:ListItem> <asp:ListItem Value = "M" > Multiple Choices (checkboxes) < / asp:ListItem> <asp:ListItem Value = "T" > Text (textbox) < / asp:ListItem> < / asp:DropDownList> < / EditItemTemplate> <InsertItemTemplate> <asp:DropDownList ID = "DropDownList3" runat = "server" SelectedValue = ' <% # Bind("AnswerType") %> '> <asp:ListItem
Any idea to display list of questions with answer as radio buttons ? Hi, I want to display a number of question's with their answers as radio buttons in row wise on the page and when finish will get the checked radio button value from each of row. That question's and answers are stored in a database WriteLine ( "Exception in DBHandler" + ex ); return null ; } finally { myConnection . Close (); } } protected void Page_Load ( object sender , EventArgs e ) { List < Questions > QList = DatabaseConnecter . LoadQuestions (); Random rndNumber = new Random (); int randomQuest = rndNumber . Next ( 30 Question 1"> < / asp : Label > < / td > < td > < asp : RadioButtonList ID = "rbAnswer1" runat = "server" RepeatDirection = "Horizontal"> < asp : ListItem Text = "A. 1" Value = "1"> < / asp : ListItem > < asp : ListItem Text = "B. 2" Value = "2"> < / asp
System.Windows.Forms.RadioButton optDetails; internal System.Windows.Forms.RadioButton optSmallIcon; internal System.Windows.Forms.Button cmdFillList; internal System.Windows.Forms.ListView listAuthors; internal System.Windows.Forms.ImageList imagesLarge; internal System Forms.RadioButton(); this .optSmallIcon = new System.Windows.Forms.RadioButton(); this .cmdFillList = new System.Windows.Forms.Button(); this .listAuthors = new System.Windows.Forms.ListView(); this .imagesLarge = new System.Windows.Forms.ImageList( this summary> [STAThread] static void Main() { Application.Run( new ListViewExample()); } private void cmdFillList_Click( object sender, System.EventArgs e) { DataTable dt = StoreDB.GetProducts(); / / Suspending automatic refreshes as items are added / removed. listAuthors.BeginUpdate(); listAuthors.SmallImageList = imagesSmall; listAuthors.LargeImageList = imagesLarge; foreach (DataRow dr in dt.Rows) { ListViewItem listItem = new ListViewItem(dr[ "ModelName" ].ToString listItem.ImageIndex = 0; / / Add sub-items for Details view. listItem.SubItems.Add(dr[ "ProductID" ].ToString()); listItem.SubItems.Add(dr[ "Description" ].ToString()); listAuthors.Items.Add(listItem); } / / Add column headers for Details view. listAuthors.Columns.Add( "Product" , 100, HorizontalAlignment.Left); listAuthors.Columns