Question

Im creating radiobuttonlist accordingly. I want space in between them. All are done in code behind.

                RadioButtonList ddlst1 = new RadioButtonList();
                for (int k = 1; k < 5; k++)
                {

                    ddlst1.Items.Add(k.ToString());


                }                                  
                ddlst1.SelectedValue = i < choice1.Count() ? choice1[i] : string.Empty;
                ddlst1.RepeatDirection = RepeatDirection.Horizontal;
                ddlst1.AutoPostBack = false;      
Was it helpful?

Solution

You can also use cellpadding and cell spacing(But its at design time)

<asp:RadioButtonList ID="ddlst1" runat="server" CellPadding="3" CellSpacing="2">

If you want to give at code behind then follow above answer i.e..ddlst1.Items[k].Attributes.CssStyle.Add("margin-right:5px;")

OTHER TIPS

I would attempt a css based approach

Looks like there is a solution here:

How do I add space between items in an ASP.NET RadioButtonList

Inside your for loop:

ddlst1.Items[k].Attributes.CssStyle.Add("margin-right:5px;")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top