473,386 Members | 1,693 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,386 software developers and data experts.

How to set values in datagrid?

Hi all,
I am using Datagrid control in VB.Net 2003.
Now I have a problem like this,
when user changed the value in a cell in datagrid, I want all the
values in the same column below the current row changed to the new
value.
How can I do this?
I use currentcellchaged event like below:

Private Sub myGRID_CurrentCellChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles myGRID.CurrentCellChanged
''''Get total row count
Dim i as Integer
Dim NewValue as Integer
NewValue=CInt(myGRID.Item(myGRID.CurrentRowIndex,
ColumnNumber))
i = myGRID.BindingContext(Me.ALLOCATIONS_GRID.DataSour ce,
myGRID.DataMember).Count()
If (myGRID.CurrentRowIndex + 1) < i Then
myGRID.Item(myGRID.CurrentRowIndex + 1, ColumnNumber) =
NewValue
End If
End Sub
Can anybody advise on this?
I always get "ListManager's position must equal to rownum" exception.
Thanks.
Regars,
Michael

Jan 28 '08 #1
5 1691
Michael,
A datagrid is a data control.

To access it you can the most simple use the object in the datasource (a
dataview or a datatable).

That is simple to do with a for each or a for index loop.
Cor

Jan 28 '08 #2
On Jan 29, 1:16*am, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
Michael,

A datagrid is a data control.

To access it you can the most simple use the object in the datasource (a
dataview or a datatable).

That is simple to do with a for each or a for index loop.

Cor
Thanks Cor,
Would you please tell me more if I do this in the datatable?
What event should I put the code in?
Thanks.

Regards,
Michael
Jan 29 '08 #3
Sorry,
\\\
dim dt as DataTable = DirectCast(TheDataGrid.DataSource, DataTable)
///
Jan 29 '08 #4
On Jan 30, 3:03*am, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
Sorry,\\\

dim dt as DataTable = DirectCast(TheDataGrid.DataSource, DataTable)
///
Hi Cor,
thanks for your help.
But what I want is like this,
I have a datatable, and use a datagrid to display it.
users want to modify the value in datagrid,
let's say he changed the value in row 1, column 1,
now I have to changes all the values in coumn 1 for the other rows.
I guess I should make this change in some datagrid event, because this
should be invoked automatically.
That is, after users modify the value in a cell, datagrid will
automatically change the value in below rows.
Hope this make sense.
Thanks.

Regards,
Michael
Jan 30 '08 #5
Michael,

See this sample on our pages.
http://www.vb-tips.com/DataGridRowCount.aspx

This gives you the count, however you can as well get the position and set
it than as starting index in a for index loop instead of the for each loop
that I have showed you,

Cor
Jan 30 '08 #6

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

Similar topics

1
by: Derek | last post by:
Another DGrid question... I can not access the values of a cell in a datagrid unless I make them visible. I do not want these fields displayed. I only want to use the values to run a stored...
4
by: Job Lot | last post by:
On form load my datagrid gets populated with values from database table. How can I reset values in my DataGrid to 0 on click of a button? thanks
0
by: Gamze | last post by:
Hi, How can i get values from datagrid to combobox and should select the same name as in datagrid row on the combobox control In my vb.net windows application ,i have combobox which is...
2
by: Balamurukan | last post by:
How to retrive property values from our own property window
3
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
0
by: Mike | last post by:
I've got an app with a DataTable that gets passed around and modified by datagrids on 3 different asp.net pages. Not all columns need to be displayed, but I need them all in the datagrid so I can...
4
by: Vik | last post by:
How can I display the lookup values in a datagrid? E.g., the datagrid displays a table that contains a ProductID field. I want to display a Product description from a Product table in that...
1
by: Arjen Hoekstra | last post by:
Hello, I've got a datagrid with a textbox in each cell. I've also two buttons, one to add a row to the datagrid and one to delete a row. A user can type data into textboxes and then submit it to...
5
by: Coleen | last post by:
Hi all :-) We are using a DB2 database connection through a class module to get the data into a datagrid in an aspx web page using VB.Net. I can get the data into the first datagrid with no...
4
by: Shawn | last post by:
This must be easy, but I can't find a way to do it. I have a datagrid displaying Rows from a Datatable. I want to take the values in the Row and ultimately use them in a SQL Where string. I would...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.