|
 |
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
source?
Regards
----- Original Message -----
From: "Huynh, Trung" <Trung.Huynh@h...>
To: "Website Programming with ASP.NET"
<aspdotnet_website_programming@p...>
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.
http://www.wrox.com/books/1861006985.htm
Message #3 by "Mathias P" <mathiaspatrikson@y...> on Fri, 28 Feb 2003 09:45:58
|
|
Hello,
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"
AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="IdTour"
HeaderText="IdTour"></asp:BoundColumn>
<asp:BoundColumn DataField="name" HeaderText="Plays
on:"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:CheckBox ID="chkPlaysOn"
OnCheckedChanged="GetIdTour" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></TD>
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
Next
//Mathias P
|
|
 |