p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

aspdotnet_website_programming thread: DataGrid

Message #1 by "Huynh, Trung" <Trung.Huynh@h...> on Fri, 21 Feb 2003 17:33:23 -0600
Anyone know how to read from DataGrid into Code?
Message #2 by "Jerry Lanphear" <jerrylan@q...> on Sat, 22 Feb 2003 08:25:59 -0700
Huynh, Trung

I know how to do just about everything a DataGrid can do, but I am sorry I
do not understand your question. Do you mean reading the code as the data

----- Original Message -----
From: "Huynh, Trung" <Trung.Huynh@h...>
To: "Website Programming with ASP.NET"
Sent: Friday, February 21, 2003 4:33 PM
Subject: [aspdotnet_website_programming] DataGrid

Anyone know how to read from DataGrid into Code?

Professional Design Patterns in VB.NET:
Building Adaptable Applications

Want to know how design patterns bring reusable
design and adaptabilty to your applications? How
to recognize the need for a design pattern
solution? How to select, design, and implement
the right patterns? How parts of the .NET Framework
(like the .NET Data Providers and .NET Remoting)
take advantage of design patterns? This book
presents a practical approach to using design
patterns in VB.NET, by focusing on the relevance
of design patterns in the different tiers of a
distributed n-tier architecture.


Message #3 by "Mathias P" <mathiaspatrikson@y...> on Fri, 28 Feb 2003 09:45:58
I?ve got a datagrid to which I databind a dataset that has two columns, I 
also add a checkbox column to the datagrid. At a given moment I want to 
loop through the datagrid to get the value from the checkbox and the 
value from one of the other columns (column name: IdTour) in the datagrid 
to use those to make an insert in the DB. I?ve got the code to loop 
through the datagrid and to get the values from the checkboxes, but I 
don?t have the code to get the value from the other columns. Can anyone 
help me out with this one?

The .ASP code for the datagrid is as follows: 

<asp:datagrid id="dgPlaysOn" runat="server" Height="103px" 
		<asp:BoundColumn DataField="IdTour" 
		<asp:BoundColumn DataField="name" HeaderText="Plays 
		<ItemStyle HorizontalAlign="Center"></ItemStyle>
				<asp:CheckBox ID="chkPlaysOn" 
OnCheckedChanged="GetIdTour" Runat="server" />

And the code in the code behind section is as follows: 

Dim i As Byte 'Loop index
Dim item As DataGridItem 'used to access the individual grid items
Dim cbPlaysOn As CheckBox 'Used to acces the individual checkbox 
Dim bPlaysOn As Boolean

For i = 0 To dgPlaysOn.Items.Count - 1
	item = dgPlaysOn.Items(i)
      cbPlaysOn = CType(item.FindControl("chkPlaysOn"), CheckBox)
      bPlaysOn = cbPlaysOn.Checked
      'Put code to access a specific cell in the column IdTour

      'Put code to call the insert statement

//Mathias P

  Return to Index