473,287 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Overall editing DataGrids

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?

Thanks

Also see my old Post:
Mike,

Thanks.

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"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox> </ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 8px; POSITION:absolute; TOP: 8px" runat="server"
Text="Button"></asp:Button>
</form>

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
DataGrid1.Attributes.Remove("style")
Button1.Attributes.Remove("style")

If Not Page.IsPostBack Then
Dim MyList As New ArrayList
Dim i As Int32
For i = 0 To 3
MyList.Add(i)
Next
DataGrid1.DataSource = MyList
DataGrid1.DataBind()
Else
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
Next
End If
End Sub
Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit thehttp://www.microsoft.com/protect 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*******@discussions.microsoft.com>
Sender: "Sebi" <an*******@discussions.microsoft.com>
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;
charset="iso-8859-1"
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 10.40.1.165
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
SelectAll/DeselectAll.

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

Sebi


Nov 17 '05 #1
0 1010

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ux | last post by:
ServerSide: PHP+MySql ClientSide: JS (IE5+, Moz1.7) I need to edit an HTML table that contains records from a table in MySQL. A MsAccess datagrid or similar behaviour should be the best, but...
1
by: Simon Harris | last post by:
Hi All, I wish to populate more than one datagrid from the same OleDBCommand. The code I have is: Dim objCmd As New OleDbCommand(strSql, objConn) Then... ...
4
by: ree32 | last post by:
I have a placeholder and depending on a user input(a drop downlist) when the user clicks a button I dynamically create a number of datagrids and fill them with data from a database. But the problem...
2
by: geodev | last post by:
I’m building a small application and I have to build it using asp.net, vb.net and my database is MSDE. I have a datagrid with a list of customers and that is working great. I now need to be able...
0
by: Scott Meddows | last post by:
I'm having trouble scrolling some datagrids so they sync up... I have two identical datagrids on a form, filled with eh same dataset. I want a user to be able to scroll on the datasets and the...
12
by: Art | last post by:
Hi, I need help -- again -- I have a DataGrid with a DataTable as its source. It displays wonderfully when I put in some test data (withinin the code). Now, I'd like to change one of the...
7
by: Ausclad | last post by:
Ok, ill try again..... It seems fairly simple. I have two combo boxes in a datagrid. The datagrid is bound to a a table in a dataset. The two combo boxes are bound to a single data table...
2
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a...
6
by: =?Utf-8?B?R2VudGlhbiBIaWxh?= | last post by:
I have a datagrid that I want to be able to allow me to edit only the first two rows and all the other rows to be read-only. How can I do that? Any insight is highly appreciated. I have spent...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.