gpt4 book ai didi

c# - 如何隐藏单选按钮列表中的单选按钮之一?

转载 作者:搜寻专家 更新时间:2023-11-01 05:23:16 24 4
gpt4 key购买 nike

假设我想隐藏一个值为 0 的单选按钮,什么代码可以使它可见 = false?我使用的是 Javascript、C# 和 ASP.NET。

<asp:ListItem Value="1"> 1&nbsp</asp:ListItem>
<asp:ListItem Value="2"> 2&nbsp</asp:ListItem>
<asp:ListItem Value="3"> 3&nbsp</asp:ListItem>
<asp:ListItem Value="4"> 4</asp:ListItem>
<asp:ListItem Value="0" Selected="True" Enabled="False">

foreach (ListViewDataItem item in ListView1.Items)
{
var rbl = (RadioButtonList)item.FindControl("rblSelect");
var selectedValue = int.Parse(rbl.SelectedItem.Value);
var selectedText = rbl.SelectedItem.Text;
var selectedIndex = rbl.SelectedIndex;
rbl.Items[0].Attributes.CssStyle.Add("visibility", "hidden");
}

最佳答案

试试这个:来自 CodeBehind

MyRadioButtonList.Items[0].Attributes.CssStyle.Add("visibility", "hidden");

编辑:

int count = 0; //index of item tobe hidden
foreach (ListViewDataItem item in ListView1.Items)
{


var rbl = (RadioButtonList)item.FindControl("rblSelect");
var selectedValue = int.Parse(rbl.SelectedItem.Value);
var selectedText = rbl.SelectedItem.Text;
var selectedIndex = rbl.SelectedIndex;

if(count == 0)
rbl.Attributes.CssStyle.Add("visibility", "hidden");

count++;
}

关于c# - 如何隐藏单选按钮列表中的单选按钮之一?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22434765/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com