How Do I : add Checkbox updates without using edit/upate/cancel

C

Charles

Hello,
I need to display rows in a grid and then allow the user
to click one or more checkboxes, one per column and have
each click a seperate process/update.
I DO NOT WHAT TO use the edit mode and then the user
selects update or cancel. Too many click.

I am using the datagrid control.
One click, one SQL update.

Charles
 
J

J P Deka

Charles
This is little tricky for this first make one functions
(1) Binddata -- the function job is to get datatable and bind it.

here is the listing
-------------------
Function Binddata()

Dim bc1 As New BoundColumn()

Dim bc2 As New BoundColumn()

Dim tc As New TemplateColumn()



bc1.DataField = "XXX" /// coulmn name

bc1.HeaderText = "COL_HEADER"

bc2.DataField = "XXX"

bc2.HeaderText = "COL_HEADER"

tc.ItemTemplate = New checkboxColumn() // this is the template column to
add the template of checkbox

dbgrid.Columns.Clear()

dbgrid.Columns.Add(tc)

dbgrid.Columns.Add(bc1)

dbgrid.Columns.Add(bc2)

'Adding checkbox

Dim data As DataTable = getTheData() // This function will get the data and
return the datatable

dbgrid.DataSource = data

dbgrid.AutoGenerateColumns = False

dbgrid.DataBind()

End Sub

----------------------------------------------------------------------------
-------------



Now add this class to the Module

Public Class checkboxColumn

Implements ITemplate

Public Sub New()

End Sub

Sub instantiatein(ByVal container As Control) Implements
ITemplate.InstantiateIn

Dim dyncb As CheckBox = New CheckBox()

AddHandler dyncb.DataBinding, AddressOf BindCheckBoxColumn

container.Controls.Add(dyncb)

End Sub

Public Sub BindCheckBoxColumn(ByVal sender As Object, ByVal e As EventArgs)

Dim dyncb As CheckBox = CType(sender, CheckBox)

Dim container As DataGridItem = CType(dyncb.NamingContainer, DataGridItem)

End Sub

End Class

________________________________________________________________

If you face any further problem let me know..at ([email protected])
 
Y

Yan-Hong Huang[MSFT]

Hello Charles,

You could also refer to these materials for how to customize datagrid
control:

DataGrid Control FAQ:

There are quite a few good examples around. Here are some links:

Top Questions About the DataGrid Web Server Control
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechar
t/html/vbtchtopquestionsaboutaspnetdatagridservercontrol.asp
Contents
Windows Forms versus Web Forms DataGrid Controls
Controlling Column Width, Height, and Alignment
Customizing Column Layout in Display and Edit Mode
Formatting Dates, Currency, and Other Data
Showing and Hiding Columns Dynamically
Adding Columns Dynamically
Adding New Records to a Data Source Using the DataGrid Control
Displaying a Drop-Down List in Edit Mode
Selecting Multiple Items Using a Check Box (Hotmail Model)
Editing Multiple Rows At Once
Selecting Rows by Clicking Anywhere

Cutting Edge: Server-side ASP.NET Data Binding, Part 2: Customizing
the DataGrid Control
http://msdn.microsoft.com/library/en-us/dnmag01/html/cutting0104.asp

Summary Rows in DataGrid Controls
http://msdn.microsoft.com/library/en-us/dndive/html/data01102002.asp

Cutting Edge: Custom Web Data Reporting
http://msdn.microsoft.com/library/en-us/dnmag01/html/cutting0107.asp

Cutting Edge: A Truly Excel-like Grid Control
http://msdn.microsoft.com/library/en-us/dndive/html/data02142002.asp

Hope it helps.
Best regards,
yhhuang
VS.NET, Visual C++
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
--------------------
!Content-Class: urn:content-classes:message
!From: "Charles" <[email protected]>
!Sender: "Charles" <[email protected]>
!Subject: How Do I : add Checkbox updates without using edit/upate/cancel
!Date: Wed, 9 Jul 2003 16:07:29 -0700
!Lines: 12
!Message-ID: <[email protected]>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!Thread-Index: AcNGbt6x1CIxO+afQN635+8lklhbvQ==
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:5608
!NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
!
!Hello,
! I need to display rows in a grid and then allow the user
!to click one or more checkboxes, one per column and have
!each click a seperate process/update.
! I DO NOT WHAT TO use the edit mode and then the user
!selects update or cancel. Too many click.
!
! I am using the datagrid control.
! One click, one SQL update.
!
!Charles
!
!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top