本人以前是学C#的,近来要用VB.NET,不知是不是C#比VB.NET强大还是自己不懂得转变,下面这一小段代码我尝试了好多次,想把它转成VB.NET,但都不成功,讲大家帮个忙!谢谢大家!
private void Button1_Click(object sender, System.EventArgs e)
{
string sql;
sql="";
foreach(DataGridItem item in this.DataGrid1.Items)
{
if(((CheckBox)item.FindControl ("chk")).Checked ==true)
{
sql+="id="+item.Cells[0].Text;
}
}}
最主要是if(((CheckBox)item.FindControl ("chk")).Checked ==true)这句不知道怎样转换!
private void Button1_Click(object sender, System.EventArgs e)
{
string sql;
sql="";
foreach(DataGridItem item in this.DataGrid1.Items)
{
if(((CheckBox)item.FindControl ("chk")).Checked ==true)
{
sql+="id="+item.Cells[0].Text;
}
}}
最主要是if(((CheckBox)item.FindControl ("chk")).Checked ==true)这句不知道怎样转换!
解决方案 »
- 紧急求助 : 我的gridview 在我的机子上显示中文的"添加 删除 修改"等中文字符,但是到了别人机子上显示的是英文,为啥呢?
- 数据库操作类(像SQLHelper)中的方法应该设计成静态方法,还是应该用的时候实例化一下?
- 请大家说一下 server.ClearError 的用法
- 超级无敌霹雳宇宙吉吉如律令十万火急!
- xml文件的路径问题
- 难!!如何在网页上显示实时信息?
- 急!关于windows的问题???????
- 关于windows服务出错了
- 刚才运行水晶报表,出现以下错误提示,是不是因为没有注册的原因啊?
- JSP引用activex插件的问题?
- 用asp.net开发web程序的朋友们进来,共同鉴赏!
- 如何在搜索结果中继续查找
end if
我对VB都不怎么了解
怕给你写出来万一不成丢人
帮你顶吧
For Each item In Me.DataGrid1.Items
If CType((item.FindControl("chk")), CheckBox).Checked = True Then
strsql += "id=" + item.Cells(0).Text
End If
Next
吧
If CType((item.FindControl("chk")), CheckBox).Checked = True Then
strsql += "id="&item.Cells(0).Text
End If
Next
if(((CheckBox)item.FindControl ("chk")).Checked ==true)
{
sql+="id="+item.Cells[0].Text;
}
可以执行得了,而在VB.NET中
If CType((item.FindControl("chk")), CheckBox).Checked = True Then
sql+= "id=" + item.Cells(0).Text
End If就执行不了,真怪!!!
C#能做的,vb.net也都能做