Re: [ASP ] GridView按鈕的判斷
先謝謝brian90191的回答
經修正程式如下:
Dim cmdButton As Button = CType(e.Row.FindControl("btnMod"),Button)
Dim bt1 As New Button
bt1 = CType(e.Row.FindControl("btnMod"), Button)
If cmdButton.ID = "btnMod" Then --->if 好像擋不下來
Dim lb1, lb2 As New Label
Response.Write(bt1.Text.ToString
............
執行到
cmdButton.OnClientClick =
"javascript:window.open('FilModVer.aspx?id_no=" + lb1.Text.Trim &
"&title_nm=" & lb2.Text.Trim +
"',null,'status=yes,left=350,top=200,width=350,height=250')"
還是出現
並未將物件參考設定為物件的執行個體
還請各位大大幫看下程式,或有什麼可以參考的資料
先謝謝大家的回答
※ 引述《b8888 (b8888)》之銘言:
: 各位大大好
: 小弟寫了個程式,其中有一個GridView1,有二個button
: commandField,另一個則是button(btnMod)
: commandfield是執行編輯文字方塊用的
: button(btnMod)則是開新視窗,會帶參數
: 我的問題,二個按鈕都會執行
: cmdButton.OnClientClick = "javascript:w ........
: 但是commandfield執行到
: cmdButton.OnClientClick = "javascript:w ........
: 程式就掛了,VS了2010秀出”並未將物件參考設定為物件的執行個體"
: 我想大概是commandField,沒有new的關係
: 所以我加入了判斷,找Text = "連結"的,但還是一樣
: if 那段好像沒有擋下來
: 錯誤的原因還是 "並未將物件參考設定為物件的執行個體。"
: 可否幫忙看一下程式,或有什麼資料可以參考的
: 先謝謝大家的回答
: Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
: System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
: If e.Row.RowType = DataControlRowType.DataRow Then
: Dim cmdButton As Button = e.Row.FindControl("btnMod")
: Dim bt1 As New Button
: bt1 = CType(e.Row.FindControl("btnMod"), Button)
: >>>>>If cmdButton.Text = "連結" Then
: Dim lb1, lb2 As New Label
: Response.Write(bt1.Text.ToString)
: lb1 = CType(e.Row.FindControl("Label1"), Label)
: lb2 = CType(e.Row.FindControl("Label2"), Label)
: cmdButton.OnClientClick =
: "javascript:window.open('FilModVer.aspx?id_no=" + lb1.Text.Trim &
: "&title_nm=" & lb2.Text.Trim +
: "',null,'status=yes,left=350,top=200,width=350,height=250')"
: End If
: End If
: End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.47.209.91
→
01/13 15:36, , 1F
01/13 15:36, 1F
→
01/13 20:13, , 2F
01/13 20:13, 2F
→
01/13 23:02, , 3F
01/13 23:02, 3F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):