RadioButtonList 内的 ASP.Net RadioButton 可见性

发布于 2024-07-04 16:31:11 字数 45 浏览 4 评论 0原文

有没有办法以编程方式隐藏 RadioButtonList 控件内的单选按钮?

Is there a way to hide radio buttons inside a RadioButtonList control programmatically?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

孤者何惧 2024-07-11 16:31:11

尝试这个:

RadioButtonList.Items.Remove(RadioButtonList.Items.FindByValue("3"));

Try This:

RadioButtonList.Items.Remove(RadioButtonList.Items.FindByValue("3"));
吹梦到西洲 2024-07-11 16:31:11

如果你的意思是使用 JavaScript,如果我没记错的话,你必须挖掘出每个 的 ClientID 属性。 标签。

If you mean with JavaScript, and if I remember correctly, you've got to dig out the ClientID properties of each <input type="radio" ...> tag.

ゝ偶尔ゞ 2024-07-11 16:31:11

您是否尝试过通过 itemdatabound 事件 onload 隐藏它,或者您是否需要它在加载后隐藏?

Have you tried to hide it through the itemdatabound event onload or do you need it to hide after it loads?

や莫失莫忘 2024-07-11 16:31:11

我还没有测试过,但我假设(对于 C#)

foreach(ListItem myItem in rbl.Items)
{
if(whatever condition)
myItem.Attributes.Add("visibility","hidden");

}

I haven't tested it, but I'd assume (for C#)

foreach(ListItem myItem in rbl.Items)
{
if(whatever condition)
myItem.Attributes.Add("visibility","hidden");

}
昵称有卵用 2024-07-11 16:31:11

RadioButtonList 内不可见的另一个答案。

试试这个代码:

RadioButtonList.Items(1).CssClass.Add("display", "none");

并让工作在布局中不显示RadioButtonList。

Another answer to not visibility inside a RadioButtonList.

Try this code:

RadioButtonList.Items(1).CssClass.Add("display", "none");

and get the job to no display RadioButtonList in layout.

極樂鬼 2024-07-11 16:31:11

为什么不根据需要添加和删除单选按钮?

RadioButtonList.Items.Add("Item Name" or index);
RadioButtonList.Items.Remove("Item Name" or index);

Why not add and remove the radio buttons as needed?

RadioButtonList.Items.Add("Item Name" or index);
RadioButtonList.Items.Remove("Item Name" or index);
染年凉城似染瑾 2024-07-11 16:31:11

以下是将样式属性应用于列表项的方法:

RadioButtonList.Items(1).Attributes.Add("style", "display:none")
- 或 -
RadioButtonList.Items(1).Attributes.Add("style", "visibility:hidden")

Here's how you have to apply a style attribute to a listitem:

RadioButtonList.Items(1).Attributes.Add("style", "display:none")
- OR -
RadioButtonList.Items(1).Attributes.Add("style", "visibility:hidden")

绮筵 2024-07-11 16:31:11

在幕后,您可以访问该项目的属性并为其分配 CSS 样式。

因此,您应该能够通过指定以下方式以编程方式分配它:

RadioButtonList.Items(1).CssClass.Add("visibility", "hidden")

并完成工作。

Under the hood, you can access the attributes of the item and assign it a CSS style.

So you should be able to then programmatically assign it by specifying:

RadioButtonList.Items(1).CssClass.Add("visibility", "hidden")

and get the job done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文