复选框的返回值。 [英] Return value of checkbox.

查看:97
本文介绍了复选框的返回值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.net中,以下代码是正确的吗?

  Dim  r1  As  Bollean = rd1.checked 



返回什么类型的值?



然后当我把以下代码---

 如果 Request.QueryString(  r1)=  True  然后 
myReportDocument.Load(Server.MapPath( Gradewise.rpt ))
结束 如果 '



它出现以下错误 -



从字符串到布尔类型的转换无效。

解决方案

有无看看这里:复选框。已检查的属性(web.ui.webcontrols) [ ^ ]和这里: FindControl方法 [ ^ ]



  Dim  myCbx 作为控件=  CType (FindControl(  CheckBox1 ),CheckBox)
如果 myCbx Nothing AndAlso myCbx.Checked 然后 DoSomething()





其他资源:如何:按ID访问服务器控件 [ ^ ]


  Dim  r1 作为 Bollean = rd1.checked 





这个输出会是一个字符串,但布尔值不接受字符串字符,所以在下面使用它。



Dim r1 As Bollean = Convert.ToBoolean(rd1.checked)


In ASP.net is the following code right ?

Dim r1 As Bollean = rd1.checked 


returns what type of value?

then when I put this following code---

If Request.QueryString("r1") = True Then
     myReportDocument.Load(Server.MapPath("Gradewise.rpt"))
End If'


It gives following error--

Conversion from string "" to type 'Boolean' is not valid.

解决方案

Have a look here: Checkbox.Checked property (web.ui.webcontrols)[^] and here: FindControl method[^]

Dim myCbx As Control = CType(FindControl("CheckBox1"),CheckBox)
If Not myCbx Is Nothing AndAlso myCbx.Checked Then DoSomething()



Other resources: How to: Access Server Controls by ID[^]


Dim r1 As Bollean = rd1.checked



the output of this will be a string but boolean will not accept string characters so use it in below way.

Dim r1 As Bollean = Convert.ToBoolean(rd1.checked)


这篇关于复选框的返回值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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