看板 Visual_Basic 關於我們 聯絡資訊
各位大大好 小弟寫了個程式,其中有一個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
brian90191:Dim cmdButton As Button = CType(e.Row.FindControl 01/13 04:04
brian90191:("btnMod"),Button) 01/13 04:04