如何防止asp:RadioButtonList呈现HTML表? [英] How can I prevent asp:RadioButtonList from rendering a HTML-Table?

查看:94
本文介绍了如何防止asp:RadioButtonList呈现HTML表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想呈现一个-控件的简单列表.我的ASP.NET后台代码如下:

I would like to render a simple list of - Controls. My ASP.NET Code-behind looks like:

RadioButtonList list = new RadioButtonList();
                    list.ID = rbl.name;
                    list.CssClass = rbl.cssClass;

                    foreach (radio radio in rbl.radio)
                    {
                        ListItem li = new ListItem();
                        li.Text = radio.label;
                        li.Value = radio.value;
                        li.Selected = radio.@checked;
                        list.Items.Add(li);

                    }

但是RadioButtonList自动呈现HTML表.如果我使用HtmlInputRadioButton,则一切正常,但在RenderControl()上崩溃

But the RadioButtonList renders automatically a HTML-Table. If I use HtmlInputRadioButton everything works fine but it crashes on RenderControl()

推荐答案

您应该查看

使用此属性可以指定是否在表中显示RadioButtonList控件中的项目.如果将此属性设置为RepeatLayout.Table,则列表中的项目显示在表中.如果将此属性设置为RepeatLayout.Flow,则列表中的项目将显示为没有表结构.

Use this property to specify whether the items in the RadioButtonList control are displayed in a table. If this property is set to RepeatLayout.Table, the items in the list are displayed in a table. If this property is set to RepeatLayout.Flow, the items in the list are displayed without a table structure.

这篇关于如何防止asp:RadioButtonList呈现HTML表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆