作者b8888 (b8888)
看板Visual_Basic
标题Re: [ASP ] GridView按钮的判断
时间Sun Jan 13 10:19:09 2013
先谢谢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
1F:→ herowa:应该是你的 lb1 or lb2 是nothing吧,不然你连if那都过不了 01/13 15:36
2F:→ b8888:谢谢brian90191、herowa的帮忙,我猪头LB2是NOTHING 01/13 20:13
3F:→ brian90191:如我稍早寄的那封信,再确认一下label噜! 01/13 23:02