如何获得单选按钮的值!!! 页面上要多个单选按钮 但名字又不相同 如何在选择时 在另一个文本框获得选中的单选按钮的值。且这些单选按钮不是直接拖上页面的 而是在程序运行时 加载的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试试Request.Form["单选按钮的名字"]; 自定义控件,单选按钮是RadioButton?请问你要的值是它的文本,还是选它后,会返回一个特定的值? 加按钮的时候同时添加autopostback=true还有就是添加事件checkedchange的委托代码 就是注册checkedchange这个事件,然后分配事件的方法 按钮就对应一个动作,所以,需要 添加事件checkedchange的委托。你在动态创建RedioButton时,就可以用一个数组来对其进行管理。这样,当点击某个按钮时,就可以从数据中找出来。 System.Collections.ArrayList listRdoBtn = new System.Collections.ArrayList(); ... System.Windows.Forms.RadioButton rdo1 = new System.Windows.Forms.RadioButton(); rdo1.Text = "radio button1"; rdo1.CheckedChanged += new EventHandler(rdo1_CheckedChanged); listRdoBtn.Add(rdo1); System.Windows.Forms.RadioButton rdo2 = new System.Windows.Forms.RadioButton(); rdo2.Text = "radio button2"; rdo2.CheckedChanged += new EventHandler(rdo2_CheckedChanged); listRdoBtn.Add(rdo2); System.Windows.Forms.RadioButton rdo3 = new System.Windows.Forms.RadioButton(); rdo3.Text = "radio button3"; rdo3.CheckedChanged += new EventHandler(rdo3_CheckedChanged); listRdoBtn.Add(rdo3); private void rdo1_CheckedChanged(object sender, EventArgs e) { string strText = ((System.Windows.Forms.RadioButton)sender).Text; // Show text in the text editor... // ... } 顶,为checkedchange事件编写委托代码即可。(我习惯把变量声明成public的,这样可以全局调用) nhibernate identifier of an instance of was altered from 16 to 1 一道很有意思的逻辑思维题? C# 怎么获得其他程序的路径? 水平有限,请大家帮忙! 初用VS2005的困惑 C# 的完成端口辅助教材 这样的查询前端界面,后端是如何生成查询语句的? 能不能用代码使DataGrid里的一个表格得到focus? 高分求救,VS.net的问题 流和文件有什么关系? 连接的表格有多个时怎么写 tablecontrol 中,我给tablecontrol添加了dragdrop事件,结果没有事件激发,怎么回事?
请问你要的值是它的文本,还是选它后,会返回一个特定的值?
还有就是添加事件checkedchange的委托代码
你在动态创建RedioButton时,就可以用一个数组来对其进行管理。这样,当点击某个按钮时,就可以从数据中找出来。 System.Collections.ArrayList listRdoBtn = new System.Collections.ArrayList();
... System.Windows.Forms.RadioButton rdo1 = new System.Windows.Forms.RadioButton();
rdo1.Text = "radio button1";
rdo1.CheckedChanged += new EventHandler(rdo1_CheckedChanged);
listRdoBtn.Add(rdo1); System.Windows.Forms.RadioButton rdo2 = new System.Windows.Forms.RadioButton();
rdo2.Text = "radio button2";
rdo2.CheckedChanged += new EventHandler(rdo2_CheckedChanged);
listRdoBtn.Add(rdo2); System.Windows.Forms.RadioButton rdo3 = new System.Windows.Forms.RadioButton();
rdo3.Text = "radio button3";
rdo3.CheckedChanged += new EventHandler(rdo3_CheckedChanged);
listRdoBtn.Add(rdo3); private void rdo1_CheckedChanged(object sender, EventArgs e)
{
string strText = ((System.Windows.Forms.RadioButton)sender).Text;
// Show text in the text editor...
// ...
}