[請益] 如何偵測Gridview裡頭的checkbox去引發程序

看板Web_Design作者 (Hug me..)時間18年前 (2007/11/22 08:56), 編輯推噓2(205)
留言7則, 5人參與, 最新討論串1/1
這是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

11/22 10:03, , 1F
雖然我完全不懂asp.net 但是你要的應該是javascript?
11/22 10:03, 1F

11/22 14:33, , 2F
script + 1
11/22 14:33, 2F

11/22 19:25, , 3F
應該不是javascript , 這應該是server side可以處理的事情
11/22 19:25, 3F

11/22 20:07, , 4F
看那個checkbox是存在資料庫裡面了還是要人去按
11/22 20:07, 4F

11/24 10:33, , 5F
是資料庫裡就會寫好的
11/24 10:33, 5F

11/27 12:48, , 6F
dim checkbox1 as new checkbox
11/27 12:48, 6F

11/27 12:49, , 7F
看錯誤訊息好像是你沒new的樣子...
11/27 12:49, 7F
文章代碼(AID): #17HDFJtO (Web_Design)