作者b8888 (b8888)
看板Visual_Basic
标题[ASP ] GridView按钮的判断
时间Sun Jan 13 03:20:43 2013
各位大大好
小弟写了个程式,其中有一个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
1F:→ brian90191:Dim cmdButton As Button = CType(e.Row.FindControl 01/13 04:04
2F:→ brian90191:("btnMod"),Button) 01/13 04:04