简体   繁体   English

从单选按钮列表而不是值中获取文本

[英]Get the text from a radiobuttonlist instead of the value

I've searched all over the internet and i can't seem to find a solution to my little problem. 我已经在互联网上进行了搜索,但似乎找不到解决我的小问题的解决方案。 i got this radiobuttonlist where i get the selected value by saying: 我得到了这个单选按钮列表,在其中我说出了选定的值:

RadioButtonList1.SelectedValue

This works great when trying to get the value 尝试获得价值时效果很好

 <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" RepeatLayout="Table" CellSpacing="50">
                        <asp:ListItem Value="1" Text="Helt enig"></asp:ListItem>
                        <asp:ListItem Value="2" Text="Delvist enig"></asp:ListItem>
                        <asp:ListItem Value="3" Text="Hverken eller"></asp:ListItem>
                        <asp:ListItem Value="4" Text="Delvist uenig"></asp:ListItem>
                        <asp:ListItem Value="5" Text="Helt uenig"></asp:ListItem>
                    </asp:RadioButtonList>

But now i've come to the point where i would like to get the text also. 但是,现在我已经到了我也想获得文本的地步。 Usually i would just get it by saying: 通常我会这样说:

   RadioButtonList1.Text;

But for some reason i just get the "Value" again. 但是由于某种原因,我只是再次获得了“价值”。 Does anyone know if there's a way to get the "Text" also? 有谁知道是否还有办法获得“文字”?

RadioButtonList1.SelectedItem.Text

这应该做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM