作者b8888 (b8888)
看板Visual_Basic
标题[.NET] 在GridView中呼叫函数
时间Fri May 24 01:25:08 2013
请输入专案类型(网站专案或者应用程式专案):asp.net (vb)
各位大大好,小弟有一个问题
即在gridview中可否有类似button.click的功能
是这样的~~
小弟有一个需求是在gridview中加入一个button
当user去按该列的button 後执行一个自订的fuction
ex:
gridview 显示如下:
yymm seq_no 栏位略... 执行function
10201 10 btnOut (button )
10202 10
10203 10
10201 20
10202 20
.............
其中btnOut 已转成template 了
以下是程式
其中funOutgrieview时每执行列就会执行一次
请问有没有什麽方法是,当我按下"btnOut"时才会去执行funOut
先谢谢您的回答
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim cmdButton As Button = CType(e.Row.FindControl("btnMod"), Button)
Dim cmdButton2 As Button = CType(e.Row.FindControl("btnOut"), Button)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim bt1, bt2, bt3 As New Button
bt1 = CType(e.Row.Cells(2).FindControl("btnMod"), Button)
bt2 = CType(e.Row.Cells(3).FindControl("btnOut"), Button)
If bt1.ID = "btnMod" Then
Dim lb1, lb2 As New Label
lb1 = CType(e.Row.FindControl("Label1"), Label)
lb2 = CType(e.Row.FindControl("Label2"), Label)
cmdButton.OnClientClick =
"javascript:window.open('a123OB.aspx?id_no=" + lb1.Text.Trim &
"&title_nm=" & lb2.Text.Trim +
"',null,'status=yes,left=350,top=200,width=400,height=250')"
End If
If bt2.ID = "btnOut" Then
Dim lb1, lb2 As New Label
lb1 = CType(e.Row.FindControl("Label1"), Label)
lb2 = CType(e.Row.FindControl("Label2"), Label)
funOut( lb1.text ,lb2.text)
End If
End If
End Sub
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.47.214.196
1F:→ MOONRAKER:写一个ButtonField,或在TemplateField内写button 05/24 04:50