為DataGrid新增CheckBox控制元件 (轉)
為DataGrid新增CheckBox控制元件 (轉)[@more@].CheckBoxDataGrid" %>
w3c//DTD HTML 4.0 Transitional//EN">
為DataGrid新增CheckBox控制元件的例子
microsoft .NET 7.0">
7.0">
script">
intellisense/">
RM id="frmMain" method="post" runat="server">
edItemStyle Font-Size="9pt" Font-Names="宋體">
Public Class CheckBoxDataGrid
Inherits System.Web.UI.Page
Protected WithEvents cmdSelectAll As System.Web.UI.WebControls.Button
Protected WithEvents dgMain As System.Web.UI.WebControls.DataGrid
Protected WithEvents cmdFindSelected As System.Web.UI.WebControls.Button
Dim oDataView As DataView
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Dim nnectionString As String = "Provr=Microsoft.Jet.OLEDB.4.0;Data ="_
+ Server.MapPath("Test.mdb")
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
buggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System., ByVal e As System.EventArgs)_
Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles MyBase.Load
'Put user code to initialize the page here
dgMain.Columns(0).HeaderText = "選項"
dgMain.Columns(1).HeaderText = "序號"
dgMain.Columns(2).HeaderText = "標題"
cmdFindSelected.Text = "檢視選中的專案"
RefreshGrid()
If Not Page.IsPostBack Then
cmdSelectAll.Text = "全部選中"
dgMain.DataBind()
End If
End Sub
#Region "處理多選"
Private Sub cmdSelectAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles cmdSelectAll.Click
selectAll()
End Sub
Private Sub selectAll()
Dim oDataGridItem As DataGridItem
Dim chkExport As System.Web.UI.WebControls.CheckBox
If cmdSelectAll.Text = "全部選中" Then
For Each oDataGridItem In dgMain.Items
chkExport = oDataGridItem.FindControl("chkExport")
chkExport.Checked = True
Next
cmdSelectAll.Text = "全部不選"
Else
For Each oDataGridItem In dgMain.Items
chkExport = oDataGridItem.FindControl("chkExport")
chkExport.Checked = False
Next
cmdSelectAll.Text = "全部選中"
End If
End Sub
#End Region
#Region "DataGrid"
Private Sub RefreshGrid()
Dim oConnection As OleDbConnection
Dim oCommand As OleDbDataAdapter
Dim oDataSet As New DataSet()
Try
Dim s As String = "Select top 5 * from TestTable order by id"
oConnection = New OleDbConnection(sConnectionString)
oCommand = New OleDbDataAdapter(sSQL.ToString, oConnection)
oCommand.Fill(oDataSet, "TestTable")
oDataView = New DataView(oDataSet.Tables("TestTable"))
dgMain.DataSource = oDataView
oConnection.Close()
Catch ex As Exception
'// Place Error Handling here
End Try
End Sub
#End Region
Private Sub cmdFindSelected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles cmdFindSelected.Click
Dim oDataGridItem As DataGridItem
Dim chkExport As System.Web.UI.WebControls.CheckBox
Dim oExArgs As New System.Collections.ArrayList()
Dim sID As String
Label1.Text = ""
For Each oDataGridItem In dgMain.Items
chkExport = oDataGridItem.FindControl("chkExport")
If chkExport.Checked Then
Label1.Text = ""
sID = CType(oDataGridItem.FindControl("lblColumn"), Label).Text
oExArgs.Add(sID)
Dim i As Integer = 0
For i = 0 To oExArgs.Count - 1
Label1.Text += oExArgs(i) + ","
Next
End If
Next
End Sub
End Class
為DataGrid新增CheckBox
playground.com/">
x" target=_blank>檢視例子
CheckBoxDataGrid.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752019/viewspace-957929/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 在DataGrid頁首上新增全選的CheckBox控制元件控制元件
- WPF中Datagrid控制元件新增行號控制元件
- DataGrid控制元件通用列印類. (轉)控制元件
- easyui datagrid editor checkbox 選中UI
- 利用Session紀錄datagrid模板列中CheckBox的狀態 (轉)Session
- DataGrid 中新增資料
- Raise Server-Side Click Event of CheckBox in a DataGrid Template ColumnAIServerIDE
- .NET中新增控制元件陣列 (轉)控制元件陣列
- Flutter控制元件-- CheckBox 和 CheckboxListTileFlutter控制元件
- WPF CheckBox控制元件 我全都要控制元件
- 給datagrid控制元件建立穩固的雙向排序(asp.net) (轉)控制元件排序ASP.NET
- DataGrid中通過CHECKBOX來修改庫裡某個欄位的值
- 訊息處理:利用控制元件的動態派生[RunTime],為控制元件新增該控制元件未定義的訊息對映 (轉)控制元件
- 【MAUI】為 Label、Image 等控制元件新增點選事件UI控制元件事件
- JavaScript動態新增checkbox核取方塊JavaScript
- 為FreeBSD新增新硬碟(轉)硬碟
- 驗證使用者必選CheckBox控制元件控制元件
- 在Windows Form 中可以繫結非bool型別資料的CheckBox控制元件 (轉)WindowsORM型別控制元件
- DataGrid中巢狀使用Repeater (轉)巢狀
- EnableViewState="false"的DataGrid分頁 (轉)ViewFalse
- Qt動態新增控制元件QT控制元件
- 動態新增easyui 控制元件UI控制元件
- EasyUI 中 DataGrid 控制元件 列 如何繫結物件中的屬性UI控制元件物件
- ElementUI的Table表格新增自定義頭CheckBox多選框UI
- asp.net中DataGrid效能測試 (轉)ASP.NET
- 為網頁新增活動的背景音樂 (轉)網頁
- 全選或者單選checkbox的值動態新增到div
- ASP.NET 2.0:棄用 DataGrid 吧,有新的網格控制元件了!ASP.NET控制元件
- C#中實現DataGrid雙向排序(轉)C#排序
- ASP.NET中的DataGrid的屬性 (轉)ASP.NET
- WPF給控制元件新增運動動畫控制元件動畫
- 批量新增、刪除控制元件組--【ssnc】控制元件
- 控制元件 (轉)控制元件
- wpf 視窗程式下將datagrid匯出為excelExcel
- 轉:虛擬機器中為Linux新增硬碟虛擬機Linux硬碟
- Flutter 基礎控制元件篇-->單選框(Switch)、核取方塊(Checkbox)Flutter控制元件
- -新增 FileDrop 屬性到 視覺化控制元件(visual control) 中- (轉)視覺化控制元件
- 建立固定表頭、表格體滾動的DataGrid (轉)