作者chungyung (Hug me..)
看板Web_Design
标题[请益] 如何侦测Gridview里头的checkbox去引发程序
时间Thu Nov 22 08:56:50 2007
这是asp.net的网页
目前我有张表
┌─┬─┬─┬─┬─┬─┬─┬─┐
│号│姓│迟│早│旷│图│图│图│
│码│名│到│退│课│1│2│3│
├─┼─┼─┼─┼─┼─┼─┼─┤
│01│ A│V │ │ │ │ │ │
└─┴─┴─┴─┴─┴─┴─┴─┘
试问我要如何去判断因为迟到引发图1的Visible="true"
Dim Checkbox1 As CheckBox =
CType(GridView1.Rows(i).Cells(2).FindControl("Checkbox1"), CheckBox)
Dim checkbox2 As CheckBox =
CType(GridView1.Rows(i).Cells(3).FindControl("checkbox2"), CheckBox)
Dim checkbox3 As CheckBox =
CType(GridView1.Rows(i).Cells(4).FindControl("checkbox3"), CheckBox)
Dim image1 As Image = CType(GridView1.Rows(i).Cells(5).FindControl("image1"),
Image)
Dim image2 As Image = CType(GridView1.Rows(i).Cells(6).FindControl("image2"),
Image)
Dim image3 As Image = CType(GridView1.Rows(i).Cells(7).FindControl("image3"),
Image)
可是如果我加上判断式
if chechbox1.checked= true then
image1.visible=true
end if
这个样子执行结果会是
并未将物件参考设定为物件的执行个体
描述: 在执行目前 Web 要求的过程中发生未处理的例外情形。请检阅堆叠追踪以取得错
误的详细资讯,以及在程式码中产生的位置。
例外详细资讯: System.NullReferenceException: 并未将物件参考设定为物件的执行个
体
请问各位我该如何修改我的程式码
我改了二天,看了很多网页我还是不了解
拜托大家了(〒△〒)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.231.151.173
1F:推 buganini:虽然我完全不懂asp.net 但是你要的应该是javascript? 11/22 10:03
2F:→ forkome:script + 1 11/22 14:33
3F:→ TonyQ:应该不是javascript , 这应该是server side可以处理的事情 11/22 19:25
4F:推 buganini:看那个checkbox是存在资料库里面了还是要人去按 11/22 20:07
5F:→ chungyung:是资料库里就会写好的 11/24 10:33
6F:→ fosterer:dim checkbox1 as new checkbox 11/27 12:48
7F:→ fosterer:看错误讯息好像是你没new的样子... 11/27 12:49