我有一个RadioButtonList控件。如何更改列表中只有一个raido按钮的选择? asp.net [英] I have one RadioButtonList control. How to make changes on selection of just one raido button of the list ? asp.net

查看:71
本文介绍了我有一个RadioButtonList控件。如何更改列表中只有一个raido按钮的选择? asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个RadioButtonList控件。

如何更改列表中只有一个raido按钮的选择?在选择上述以外的单选按钮时,不应发生任何变化。



我只想在下面的代码中检查最后一个单选按钮(无津贴)时进行更改。



 <   asp:RadioButtonList     ID   =  RadioButtonList1     runat   = < span class =code-keyword> server    

< span class =code-attribute> < span class =code-attribute> RepeatDirection = 水平 >
< asp:ListItem > 已修复< / asp:ListItem >
< asp:ListItem > 变量< / asp: ListItem >
< asp:ListItem > 费用涵盖< / asp:ListItem >
< asp:ListItem > 无津贴< / asp:ListItem >
< SP class =code-keyword>< / asp:RadioButtonList >

解决方案

更改此类代码



 <   asp:RadioButtonList     ID   =  RadioButtonList1    AutoPostBack   =  true    runat   =  server  
< span class =code-attribute> < span class =code-attribute> RepeatDirection = 水平 OnSelectedIndexChanged < span class =code-keyword> = RadioButtonList1_SelectedIndexChanged >
< asp:ListItem > 已修复< / asp:ListItem >
< asp:ListItem > 变量< / asp:ListItem >
< asp:ListItem > 费用涵盖< ; / asp:ListItem >
< asp:ListItem > No Stipend < / asp:ListItem < span class =code-keyword>>
< / asp:RadioButtonList >




$ c $ b在cs页面添加以下



<前lang =cs> 受保护 void RadioButtonList1_SelectedIndexChanged( object sender,EventArgs e)
{
if (RadioButtonList1.SelectedItem.Text == No Stipend
{
// 您的代码
}
}


使用OnSelectedIndexChanged < a href =http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.selectedindexchanged(v=vs.110).aspx>活动 [ ^ ]



在这种情况下,您可以检查所选项目是否无津贴是否有文本或数据库中的值。



如果你能做的话

 RadioButtonList rdbl =(RadioButtonList)sender; 
var selectedValue = rdbl.SelectedItem.Value;
var selectedText = rdbl.SelectedItem.Text;


I have one RadioButtonList control.
How to make changes on selection of just one raido button of the list ? While selection of radio button other than this mentioned above, no change should occur.

I want to make change only when last radio button(No stipend) from below code is checked.

<asp:RadioButtonList ID="RadioButtonList1" runat="server" 

                        RepeatDirection="Horizontal">
                        <asp:ListItem>Fixed</asp:ListItem>
                        <asp:ListItem>Variable</asp:ListItem>
                        <asp:ListItem>Expenses Covered</asp:ListItem>
                        <asp:ListItem >No Stipend</asp:ListItem>
                    </asp:RadioButtonList>

解决方案

change code like this

<asp:RadioButtonList ID="RadioButtonList1" AutoPostBack="true" runat="server"
                       RepeatDirection="Horizontal" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
                       <asp:ListItem>Fixed</asp:ListItem>
                       <asp:ListItem>Variable</asp:ListItem>
                       <asp:ListItem>Expenses Covered</asp:ListItem>
                       <asp:ListItem >No Stipend</asp:ListItem>
                   </asp:RadioButtonList>



in cs page add following

protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (RadioButtonList1.SelectedItem.Text == "No Stipend")
        {
            //your code
        }
    }


Use the OnSelectedIndexChanged event[^]

In that event you can check if the selected item ha No Stipend has text or the value from the database.

In the event you can do

RadioButtonList rdbl = (RadioButtonList)sender;
var selectedValue = rdbl.SelectedItem.Value;
var selectedText = rdbl.SelectedItem.Text;


这篇关于我有一个RadioButtonList控件。如何更改列表中只有一个raido按钮的选择? asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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