【问题标题】:how to display selected value from radiobuttonlist如何显示单选按钮列表中的选定值
【发布时间】:2012-04-08 04:58:42
【问题描述】:

我试过了

Dim theme = rblTheme.Items(rblTheme.SelectedIndex).Value

选择第一个值

Dim theme = rblTheme.SelectedItem.Value

选择第一个值

Dim theme = ""
        For i As Integer = 0 To rblTheme.Items.Count - 1

            If (rblTheme.Items(i).Selected) Then
                theme = rblTheme.Items(i).Value
            End If
        Next

选择两个值。

需要帮助!!

【问题讨论】:

    标签: asp.net vb.net radiobuttonlist


    【解决方案1】:
     Dim selectedItemVal as string
     selectedItemVal=rblTheme.SelectedValue;
    

    我猜您正在重新加载页面回发中的 RadioButton 列表(当您单击某个按钮时)。因此,如果 isPostBack 属性为 false,您可能应该移动该代码

     protected void Page_Load(object sender, EventArgs e)
     {
         if(!IsPostBack)
         {
            //Your code to load the Radio button list control
         }
     }
    

    现在您应该可以获取按钮单击事件的值了。

    【讨论】:

    • @coders_zone :检查我更新的答案。调试时使用 Visual Studio 断点查看下拉菜单的内容
    • 是的,我把它放在if 条件中,现在它可以工作了!!谢谢!!
    猜你喜欢
    • 2019-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-03
    相关资源
    最近更新 更多