Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,i am using radiobutton list.
C#
<asp:RadioButtonList ID="rdoStatus" runat="server" AutoPostBack="true" repeatdirection="Horizontal "OnSelectedIndexChanged="rdoStatus_SelectedIndexChanged">

C#
for (int i = 0; i <= rdoStatus.Items.Count - 1; i++)
{
  if (rdoStatus.Items[i].Selected == true)
  {
       string keyitem = rdoStatus.Items[i].Text;
       int subsubMenuItemId = Convert.ToInt32(rdoStatus.Items[i].Value);
       objcomp.AddCompanyAppTools(objcomp.CompId, objStatusSubMenuId, subsubMenuItemId);
  }
}

when i say repeat direction to horizontal .. for both the items in radiobutton list if (rdoStatus.Items[i].Selected == true) is set to true.. i mean its taking both the values even if i saelected only one ..??


when i remove this property repeat direction .. it takes only one value which is actually selected ..whay so ?? i just i want to set position of radiobutton list to hozizontal manner ,, thats it
Posted
Updated 13-Oct-13 21:07pm
v2
Comments
ShridharPanigrahi 14-Oct-13 3:17am    
Weird Behaviour. Repeat Direction property is only for displaying the Radio Buttons in vertical or horizontal position. Can you post some addtional data as in source of your Radio button list, some screens shots of rdoStatus.Items[i].Selected being set to true twice (which seems highly unlikely). This would help in analyzing your problem better.

1 solution

Hey there,

I am not sure why you are getting that problem, but to get the Selected Item's Text and Value you could use the SelectedItem of RadioButtonList instead of a loop, since it only lets you select only 1 item.
C#
if (rdoStatus.SelectedItem != null)
                {
                    string keyitem = rdoStatus.SelectedItem.Text;
                    int subsubMenuItemId = Convert.ToInt32(rdoStatus.SelectedItem.Value);    
                }


Let me know if it helps.

Azee...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900