ASP.NET-GRIDVIEW各種大小事記錄
RowDataBound
取DataKey:
GridVeiw.DataKeys(e.Row.RowIndex).Value.ToString
FindControl一定要服用:
If e.Row.RowType = DataControlRowType.DataRow Then
判斷操作模式:
If e.Row.RowState = DataControlRowState.Edit Then
FindControl:
Dim ddl As DropDownList = CType(e.Row.FindControl("ddl_PROC_KIND"), DropDownList)
偶數列無法判斷解決:
If e.Row.RowState = DataControlRowState.Edit OrElse CInt(e.Row.RowState) = 5 Then
RowCommand
FindControl:
Dim ddl1 As DropDownList = DirectCast(DirectCast(e.CommandSource, Control).FindControl("欄位名稱"), DropDownList)
取DataKey:
- Dim row As GridViewRow = DirectCast(DirectCast(e.CommandSource, Control).NamingContainer, GridViewRow)
- Dim pk As Integer = Convert.ToInt32(GridView.DataKeys(row.RowIndex).Values(0))
- 如果有設定多個的話,就1、2、3
沒有留言:
張貼留言