By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,714 Members | 1,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,714 IT Pros & Developers. It's quick & easy.

Overall editing DataGrids

P: n/a
Hello All,

I'm having problems, reading the new Values from CheckBox
in a DataGrid.

my Code Behind is C#
I do exactly what other samples do, but I allways get the
Initial Values instead of the current values choosen by
the user!!

Anybody got an Idea?


Also see my old Post:


This is exactly what I do!!
I do it in C#, but exactly the same, and I can only see
the Initial Values. I've also seen another sample which
works, but mine doesn't!!?!

Anybody got a hint??

- P L E A S E ! -
-----Original Message-----
Hi Sebi,

I created a sample grid with checkboxes. I can check & uncheck the boxesand submit the form. It will list back to me (correctly) which boxes arechecked or not. I think this sample may help you.

Add a grid & a button. Set the grid to have one template column with acheck box in it.

Here's my HTML

<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 16px; POSITION:absolute; TOP: 57px" runat="server"
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox> </ItemTemplate>
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 8px; POSITION:absolute; TOP: 8px" runat="server"

Next, my code-behind is very simple. It's all in the page_load.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
'Force "flow" layout

If Not Page.IsPostBack Then
Dim MyList As New ArrayList
Dim i As Int32
For i = 0 To 3
DataGrid1.DataSource = MyList
Dim i As Int32
For i = 0 To DataGrid1.Items.Count - 1
Dim ck As CheckBox
ck = DataGrid1.Items(i).Cells(0).FindControl ("CheckBox1") Response.Write(ck.Checked & "<br>")
'add code here to select or deselect all
'update the database here
End If
End Sub
Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the site and perform the three straightforwardsteps listed to improve your computer's security.

This posting is provided "AS IS", with no warranties, and confers no rights.

Content-Class: urn:content-classes:message
From: "Sebi" <an*******>
Sender: "Sebi" <an*******>
Subject: 'Overall' Editing DataGrids
Date: Tue, 11 Nov 2003 08:38:05 -0800
Lines: 22
Message-ID: <12****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcOoci5FF7BRb9OBSVa+nWc4+8DI0g==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:190088 NNTP-Posting-Host: TK2MSFTNGXA13
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hello All,

I'm using DataGrids mainly to display Data.
Now it should be possible for some Flags to be edited.
For this reason I've added CheckBoxes to the DataGrid.

I don't want to add edit & update button.
I want to do a Global update including a

The Problem is, that the Values don't seem to be updated. When I read the Checked Flag of the Checkbox, it still
contains the Initial Value.

Is there some Command like UpdateData(false)?
Or is there a Property that I might have set wrong?
Any Other Ideas how I can read the WebPage Values?

Thanks a lot for any help


Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.