473,407 Members | 2,314 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,407 software developers and data experts.

DataGrid still...

Hi,
I've followed some advice through this forum in which I would change the
dataset value in order to change the particular cell value in datagrid via
coding.

What I'm doing now is that, if I change the first column, the second column
in the same row would display the same input as the first's. The way I did
is to take the row no. of the column edited and update the dataset in the
same row, second column. However, the datagrid actually allowed sorting and
once the it is sorted, the row to be updated in dataset would be incorrect.

Question is:
i) Is there any better way to update the dataset?

Pls advise and thanks in advance.
pcPirate
Nov 15 '05 #1
8 1299
Hi,

There's a thread in the windowsforms.controls newsgroup titled
"How to find data in sorted DataGrid control". I have given an example of
accessing the appropriate DataRow there.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"pcPirate" <ph****@hotmail.com> wrote in message
news:uy*************@TK2MSFTNGP11.phx.gbl...
Hi,
I've followed some advice through this forum in which I would change the
dataset value in order to change the particular cell value in datagrid via
coding.

What I'm doing now is that, if I change the first column, the second column in the same row would display the same input as the first's. The way I did
is to take the row no. of the column edited and update the dataset in the
same row, second column. However, the datagrid actually allowed sorting and once the it is sorted, the row to be updated in dataset would be incorrect.
Question is:
i) Is there any better way to update the dataset?

Pls advise and thanks in advance.
pcPirate


Nov 15 '05 #2
Dmitriy,
Thanks a lot for the reply,
My database table to be displayed in the datagrid has a lot of fields and it
would be quite unwise to use the dataTable (which is needed in your example)
Is there anyway still to work around with dataset? All I ask is just to get
the exact row of the dataset.

Pls. advise and thanks in advance.
pcPirate
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:eI**************@TK2MSFTNGP12.phx.gbl...
Hi,

There's a thread in the windowsforms.controls newsgroup titled
"How to find data in sorted DataGrid control". I have given an example of
accessing the appropriate DataRow there.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"pcPirate" <ph****@hotmail.com> wrote in message
news:uy*************@TK2MSFTNGP11.phx.gbl...
Hi,
I've followed some advice through this forum in which I would change the
dataset value in order to change the particular cell value in datagrid via coding.

What I'm doing now is that, if I change the first column, the second

column
in the same row would display the same input as the first's. The way I did is to take the row no. of the column edited and update the dataset in the same row, second column. However, the datagrid actually allowed sorting

and
once the it is sorted, the row to be updated in dataset would be

incorrect.

Question is:
i) Is there any better way to update the dataset?

Pls advise and thanks in advance.
pcPirate

Nov 15 '05 #3
In some cases I use a primary key field in my grid to search against the
DataTable. I apply a TableStyle to prevent the key from being displayed.

int key = (int)productGrid[productGrid.CurrentRowIndex, 0];
DataRow dr = ((DataTable)Grid.DataSource).Rows.Find(key);

It's never failed.

If you are using DataBinding and you don't have a PK for the table, you can
designate one or more columns at runtime. It will enforce that they are
unique values. I'm not sure if you can add an unbound PK field to the table.

HTH,
Eric Cadwell
http://www.origincontrols.com

"pcPirate" <ph****@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Dmitriy,
Thanks a lot for the reply,
My database table to be displayed in the datagrid has a lot of fields and it would be quite unwise to use the dataTable (which is needed in your example) Is there anyway still to work around with dataset? All I ask is just to get the exact row of the dataset.

Pls. advise and thanks in advance.
pcPirate
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:eI**************@TK2MSFTNGP12.phx.gbl...
Hi,

There's a thread in the windowsforms.controls newsgroup titled
"How to find data in sorted DataGrid control". I have given an example of
accessing the appropriate DataRow there.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"pcPirate" <ph****@hotmail.com> wrote in message
news:uy*************@TK2MSFTNGP11.phx.gbl...
Hi,
I've followed some advice through this forum in which I would change the dataset value in order to change the particular cell value in datagrid via coding.

What I'm doing now is that, if I change the first column, the second

column
in the same row would display the same input as the first's. The way I did is to take the row no. of the column edited and update the dataset in the same row, second column. However, the datagrid actually allowed

sorting and
once the it is sorted, the row to be updated in dataset would be

incorrect.

Question is:
i) Is there any better way to update the dataset?

Pls advise and thanks in advance.
pcPirate


Nov 15 '05 #4
That's a good idea... However, is Datagrid really that weak?? I mean, it's
suppose to bind the the dataset but how come there's isn't a good way to
retrieve the exact row of the dataset? isn't this a bit stupid?
Nov 15 '05 #5
DataSets themselves do not contain rows. They contain DataTables which, in
turn, contain DataRows.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"pcPirate" <ph****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
That's a good idea... However, is Datagrid really that weak?? I mean, it's
suppose to bind the the dataset but how come there's isn't a good way to
retrieve the exact row of the dataset? isn't this a bit stupid?


Nov 15 '05 #6
Dmitriy,
Okay,
i) Your example apply to DataTable
ii) My datagrid bind to DataSet

What should I do to relate the my DataSet to your example ?

pcPirate

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:e%****************@TK2MSFTNGP09.phx.gbl...
DataSets themselves do not contain rows. They contain DataTables which, in
turn, contain DataRows.

Nov 15 '05 #7
Almost nothing - the DataView returned by the appropriate CurrencyManager's
List property will already be returning the rows for a data table or a data
relation determined by the DataMember argument value for which the
CurrencyManager instance had been queried from the form's Binding Context.

So choose the DataMember argument value wisely. For parent table, it will
correspond to the table name (the TableName property value, to be exact).
For child table, the DataMember will look like:

ParentTableName.RelationName

Of course you will be provided with DataRowView instances by indexing the
DataView returned, but each DataRowView has a Row property returning the
actual, live underlying DataRow instance.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"pcPirate" <ph****@hotmail.com> wrote in message
news:ue**************@tk2msftngp13.phx.gbl...
Dmitriy,
Okay,
i) Your example apply to DataTable
ii) My datagrid bind to DataSet

What should I do to relate the my DataSet to your example ?

pcPirate

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:e%****************@TK2MSFTNGP09.phx.gbl...
DataSets themselves do not contain rows. They contain DataTables which, in turn, contain DataRows.



Nov 15 '05 #8
Dmitriy,
Thank you very very very ver..........y much!!!! I've finally got it.

Thanks a lot!!!

pcPirate.
Nov 15 '05 #9

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

Similar topics

11
by: Junkguy | last post by:
I need some help programmatically causing a row in a DataGrid to "flush" its contents to its bound data (in Visual Studio 6 using Windows Forms with C#). My issue is I want to send an update to...
5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
5
by: BBFrost | last post by:
Win2000 ..Net 1.1 SP1 c# using Visual Studio Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1 datagrid. I've come to realize that a 'block' of rows highlighted within...
5
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
4
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
7
by: DC Gringo | last post by:
I have a datagrid that won't sort. The event handler is firing and return label text, just not the sort. Here's my Sub Page_Load and Sub DataGrid1_SortCommand: -------------------- Private...
4
by: Suzanne | last post by:
Hi all, I'm having problems with datagrids and the currentcellchanged event. My problem is this: I have a datagrid on a form, if the user changes the text in a cell on the datagrid then tries to...
6
by: GaryDean | last post by:
I liked the DataGrid because I was familiar in walking through it to do custom filling and retrieval of data in cases where standard binding wouldn't do the job. I read somewhere that the object...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
8
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.