易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.NET关于强制转换问题 - .NET技术 / ASP.NET

3个radioButton
 一个Button
一个label
C# code:

protected void Button1_Click(object sender, EventArgs e)
{
string str = null;
RadioButton rdo=(RadioButton)sender;

if (rdo.Checked == true)
{
str = rdo.Text;

}
Label1.Text = str;

}


报错:无法将类型为“System.Web.UI.WebControls.Button”的对象强制转换为类型“System.Web.UI.WebControls.RadioButton”。 

ASP.NET不能像我用C#做form那样强制转换的么?
两种不同的类型哦!!
不能转换!!

if (this.radiobuttonid.Checked == true)


不能转换

这个真不行,就好像你把字符串“哈哈”转换成数字一样,没法转

buxing........



引用
if (this.radiobuttonid.Checked == true)


同意..为什么要转呢........

引用
if (this.radiobuttonid.Checked == true)

UP

不明白你想做啥 你不是可以直接获取到 radiobuttonid吗?

晕,没见过这么转换的。。。

想实现什么逻辑?

不能 你先用一个字符串接收radiobuttonid的值,然后再将这个字符串转换成object类型的

不能

好像以前写过,Asp.Net中单选按钮组可以实现吧
{{


相关问答:

asp.net中可输入的下拉框的问题 - .NET技术 / ASP.NET

Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.WebControls
Namespace CBDAspNet.WebControls.HTML
  ''' <summary>
  '' ......

asp.net后台调用js问题 - .NET技术 / ASP.NET

本人目前遇到一个难题,请各位高手、大侠帮帮忙。
我单击一个按钮时要把gridview中的数据一个一个的取出并把对应参数传递给前台的js。
我试了几种后台调前台的方式都没有成功,所以请大侠们帮帮小弟。
谢谢。
不 ......

如何用ASP读取 XML - Web 开发 / ASP

<?xml version="1.0"?>
<root>
<status>433</status>
<msg>这个是汉字</msg>
<serialno>123</serialno>
</root>
如何用ASP读取 status值 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号