☆ 有些事現在不做,就一輩子都不會做了 ☆

最新回應

一般在 GirdView 的 TemplateField 中的控制項執行 PostBack 時都需要取得目前對應的資料列。
假設在 TemplateField 中有個按鈕 Button1,當 GridView 的某列按鈕執行 PostBack 時,可以利用下述方式取得對應的資料列。

01     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
02         Dim oRow As System.Web.UI.WebControls.GridViewRow
03         Dim iRowIndex As Integer
04
05         '取得 GridView 中對應的 GridViewRow
06         oRow = CType(sender, Button).NamingContainer
07
08         '取得對應的 RowIndex
09         iRowIndex = oRow.RowIndex
10     End Sub

DotBlogs Tags: GridView TemplateField

回應

目前沒有回應.

*標 題:

*姓 名:

 電子郵件: (將不會被顯示)

 個人網頁:

*回應

登入後使用進階評論

Please add 1 and 6 and type the answer here: