473,574 Members | 13,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows Form Gird control - defficiences

1. No Columns collection.
2. No ability to easily synchronize the underlying DataTable of a DataGrid
when a row is deleted in the Grid. Once you sort (via the column headers)
all bets are off as to whether the current row index of the data grid can be
used directly as the Rows index of the DataTable. This is documented in the
DataGrid Overview.
3. No way to access the default grid table style to make minor changes to
just one column (i.e., hide it or make it's width property zero). Not even
for read-only purposes (see #1).
4. No way to easily pick up the value of a hidden column in the Grid (which
has to be hidden using Data Layer techniques, not Presentation Layer
techniques). You have to make some ASSumption about the relationship of
grid columns to DataTable columns or use some nasty hard-coding that begs
for future maintenance errors.
5. If you want to delete a row from the data grid in your Presentation
Layer, you can't directly use the DeleteRow method of the grid (see #2
above) without going into the Data Layer to FindRows the corresponding row
in the datatable. Kind of kills the idea of separation of Presentation
Layer, Business Layer and Data Layers if the Presentation Layer has to know
how to reach into a DataTable in order to know how to delete a row in a
Presentation Layer control (grid).

Is there a 3rd-party Grid control that does not suffer from these
deficiencies?
Nov 20 '05 #1
6 1445
A few observations...

1)Since the datagrid control is meant to be bound to a datasource, you have
a DataTable which does have a columns collection and is very straightforward
to access

2) Why is that a problem? You can access the data directly regardless of
where it is and the changes will be reflected in the underlying datasource.
3) This is a bit of a pain, but it's quite easy to write class to handle
this for you...here's one example but there are many more out there and once
you create this class, it's cake to manipulate it.
http://www.knowdotnet.com/articles/cgrid.html Moroever, you can create your
own component and adding designer support is quite easy in .NET
4) Agreed
5) If it's bound, I don't see what the problem is in getting this data.
The RowState will be marked accordingly if you delete it, so you can still
seperate your logic from presentation without a problem.

I have some examples I can send you if you are interested.

HTH,

Bill
"Fred Morrison" <fm*******@erol s.com> wrote in message
news:OY******** ******@TK2MSFTN GP11.phx.gbl...
1. No Columns collection.
2. No ability to easily synchronize the underlying DataTable of a DataGrid
when a row is deleted in the Grid. Once you sort (via the column headers)
all bets are off as to whether the current row index of the data grid can be used directly as the Rows index of the DataTable. This is documented in the DataGrid Overview.
3. No way to access the default grid table style to make minor changes to
just one column (i.e., hide it or make it's width property zero). Not even for read-only purposes (see #1).
4. No way to easily pick up the value of a hidden column in the Grid (which has to be hidden using Data Layer techniques, not Presentation Layer
techniques). You have to make some ASSumption about the relationship of
grid columns to DataTable columns or use some nasty hard-coding that begs
for future maintenance errors.
5. If you want to delete a row from the data grid in your Presentation
Layer, you can't directly use the DeleteRow method of the grid (see #2
above) without going into the Data Layer to FindRows the corresponding row
in the datatable. Kind of kills the idea of separation of Presentation
Layer, Business Layer and Data Layers if the Presentation Layer has to know how to reach into a DataTable in order to know how to delete a row in a
Presentation Layer control (grid).

Is there a 3rd-party Grid control that does not suffer from these
deficiencies?

Nov 20 '05 #2
small remark on point 3

you can hide a column without using the styles...
myTable.Columns (colIdx).Column Mapping = MappingType.Hid den
"Fred Morrison" <fm*******@erol s.com> wrote in message
news:OY******** ******@TK2MSFTN GP11.phx.gbl...
1. No Columns collection.
2. No ability to easily synchronize the underlying DataTable of a DataGrid
when a row is deleted in the Grid. Once you sort (via the column headers)
all bets are off as to whether the current row index of the data grid can be used directly as the Rows index of the DataTable. This is documented in the DataGrid Overview.
3. No way to access the default grid table style to make minor changes to
just one column (i.e., hide it or make it's width property zero). Not even for read-only purposes (see #1).
4. No way to easily pick up the value of a hidden column in the Grid (which has to be hidden using Data Layer techniques, not Presentation Layer
techniques). You have to make some ASSumption about the relationship of
grid columns to DataTable columns or use some nasty hard-coding that begs
for future maintenance errors.
5. If you want to delete a row from the data grid in your Presentation
Layer, you can't directly use the DeleteRow method of the grid (see #2
above) without going into the Data Layer to FindRows the corresponding row
in the datatable. Kind of kills the idea of separation of Presentation
Layer, Business Layer and Data Layers if the Presentation Layer has to know how to reach into a DataTable in order to know how to delete a row in a
Presentation Layer control (grid).

Is there a 3rd-party Grid control that does not suffer from these
deficiencies?

Nov 20 '05 #3
1) Only works if the ordinal positions of the columns in the grid exactly
match the ordinal position of the columns in the DataTable.
2) The problem is obvious: the row index of the grid cannot reliably be used
directly to manipulate (e.g., DELETE) the corresponding row in the
DataTable. If you delete a row in a grid that has been sorted, the wrong
record in the underlying DataTable gets deleted in the database. This is
clearly documented in the online help and is, in my opinion, an admission by
Microsoft that they didn't do a good job of making their windows forms
(don't know about the ASP version) grid intuitive. Instead, you have to use
"tricks" to get around the deficiency.
3) The hyperlink you posted does not work. Is there a better one I can look
at?
5) The presentation layer should never (repeat NEVER) have to know how to
figure out the primary keys of the underlying DataTable in order to make
sure the proper row in the database gets deleted (see Microsoft's admission
of this deficiency in their online help). That belongs in the Data Layer,
not the Presentation Layer. Why have three layers if the presentation layer
has to know data-specific information (like the Primary Key constraint) of
the data bound to a grid control? If Microsoft wants to simplify our lives,
don't implement something with such an glaring flaw.

"William Ryan" <do********@nos pam.comcast.net > wrote in message
news:uR******** ******@TK2MSFTN GP09.phx.gbl...
A few observations...

1)Since the datagrid control is meant to be bound to a datasource, you have a DataTable which does have a columns collection and is very straightforward to access

2) Why is that a problem? You can access the data directly regardless of where it is and the changes will be reflected in the underlying datasource. 3) This is a bit of a pain, but it's quite easy to write class to handle
this for you...here's one example but there are many more out there and once you create this class, it's cake to manipulate it.
http://www.knowdotnet.com/articles/cgrid.html Moroever, you can create your own component and adding designer support is quite easy in .NET
4) Agreed
5) If it's bound, I don't see what the problem is in getting this data.
The RowState will be marked accordingly if you delete it, so you can still
seperate your logic from presentation without a problem.

I have some examples I can send you if you are interested.

HTH,

Bill
"Fred Morrison" <fm*******@erol s.com> wrote in message
news:OY******** ******@TK2MSFTN GP11.phx.gbl...
1. No Columns collection.
2. No ability to easily synchronize the underlying DataTable of a DataGrid when a row is deleted in the Grid. Once you sort (via the column headers) all bets are off as to whether the current row index of the data grid can
be
used directly as the Rows index of the DataTable. This is documented in

the
DataGrid Overview.
3. No way to access the default grid table style to make minor changes

to just one column (i.e., hide it or make it's width property zero). Not

even
for read-only purposes (see #1).
4. No way to easily pick up the value of a hidden column in the Grid

(which
has to be hidden using Data Layer techniques, not Presentation Layer
techniques). You have to make some ASSumption about the relationship of
grid columns to DataTable columns or use some nasty hard-coding that begs for future maintenance errors.
5. If you want to delete a row from the data grid in your Presentation
Layer, you can't directly use the DeleteRow method of the grid (see #2
above) without going into the Data Layer to FindRows the corresponding row in the datatable. Kind of kills the idea of separation of Presentation
Layer, Business Layer and Data Layers if the Presentation Layer has to

know
how to reach into a DataTable in order to know how to delete a row in a
Presentation Layer control (grid).

Is there a 3rd-party Grid control that does not suffer from these
deficiencies?


Nov 20 '05 #4
Yes, you can. And as soon as you do that, you can no longer access that
column's value in the Grid to pass back to the data layer in order to have
it use a FindRows method to locate the corresponding row in the underlying
DataTable to DELETE. Best alternative: set the column's width to zero, but
that means creating another grid table style (because you can't get at the
default one to manipulate just one column's attributes - another strange
restriction that Microsoft freely admits too in its online Help).

"Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
message news:eH******** ******@TK2MSFTN GP12.phx.gbl...
small remark on point 3

you can hide a column without using the styles...
myTable.Columns (colIdx).Column Mapping = MappingType.Hid den
"Fred Morrison" <fm*******@erol s.com> wrote in message
news:OY******** ******@TK2MSFTN GP11.phx.gbl...
1. No Columns collection.
2. No ability to easily synchronize the underlying DataTable of a DataGrid when a row is deleted in the Grid. Once you sort (via the column headers) all bets are off as to whether the current row index of the data grid can
be
used directly as the Rows index of the DataTable. This is documented in

the
DataGrid Overview.
3. No way to access the default grid table style to make minor changes

to just one column (i.e., hide it or make it's width property zero). Not

even
for read-only purposes (see #1).
4. No way to easily pick up the value of a hidden column in the Grid

(which
has to be hidden using Data Layer techniques, not Presentation Layer
techniques). You have to make some ASSumption about the relationship of
grid columns to DataTable columns or use some nasty hard-coding that begs for future maintenance errors.
5. If you want to delete a row from the data grid in your Presentation
Layer, you can't directly use the DeleteRow method of the grid (see #2
above) without going into the Data Layer to FindRows the corresponding row in the datatable. Kind of kills the idea of separation of Presentation
Layer, Business Layer and Data Layers if the Presentation Layer has to

know
how to reach into a DataTable in order to know how to delete a row in a
Presentation Layer control (grid).

Is there a 3rd-party Grid control that does not suffer from these
deficiencies?


Nov 20 '05 #5
> access that column's value in the Grid

uh?
just get your table and "ask him" the data for that column...
"Fred Morrison" <fm*******@erol s.com> wrote in message
news:u3******** ******@TK2MSFTN GP09.phx.gbl...
Yes, you can. And as soon as you do that, you can no longer access that
column's value in the Grid to pass back to the data layer in order to have
it use a FindRows method to locate the corresponding row in the underlying
DataTable to DELETE. Best alternative: set the column's width to zero, but that means creating another grid table style (because you can't get at the
default one to manipulate just one column's attributes - another strange
restriction that Microsoft freely admits too in its online Help).

"Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
message news:eH******** ******@TK2MSFTN GP12.phx.gbl...
small remark on point 3

you can hide a column without using the styles...
myTable.Columns (colIdx).Column Mapping = MappingType.Hid den
"Fred Morrison" <fm*******@erol s.com> wrote in message
news:OY******** ******@TK2MSFTN GP11.phx.gbl...
1. No Columns collection.
2. No ability to easily synchronize the underlying DataTable of a DataGrid when a row is deleted in the Grid. Once you sort (via the column headers) all bets are off as to whether the current row index of the data grid can
be
used directly as the Rows index of the DataTable. This is documented in
the
DataGrid Overview.
3. No way to access the default grid table style to make minor changes

to just one column (i.e., hide it or make it's width property zero). Not

even
for read-only purposes (see #1).
4. No way to easily pick up the value of a hidden column in the Grid

(which
has to be hidden using Data Layer techniques, not Presentation Layer
techniques). You have to make some ASSumption about the relationship
of grid columns to DataTable columns or use some nasty hard-coding that

begs for future maintenance errors.
5. If you want to delete a row from the data grid in your Presentation
Layer, you can't directly use the DeleteRow method of the grid (see #2
above) without going into the Data Layer to FindRows the corresponding row in the datatable. Kind of kills the idea of separation of Presentation Layer, Business Layer and Data Layers if the Presentation Layer has to

know
how to reach into a DataTable in order to know how to delete a row in a Presentation Layer control (grid).

Is there a 3rd-party Grid control that does not suffer from these
deficiencies?



Nov 20 '05 #6
Read the table? That's the problem! Why should my presentation layer have
to know anything about how the data go into the grid, be it hand-populated
or via a table? And if the grid is populated by a table, why can't it keep
track of the data, even after the user clicks on one of the column headers?
(That last one is really strange, but at least Microsoft freely admits their
failure in their online help for the Windows data grid control). Is the
web version of the grid control just as bad as the windows form data grid
control? My applications all use windows forms, so I can only tell you my
experiences with the windows data grid control.

"Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
message news:ey******** ******@TK2MSFTN GP10.phx.gbl...
access that column's value in the Grid
uh?
just get your table and "ask him" the data for that column...
"Fred Morrison" <fm*******@erol s.com> wrote in message
news:u3******** ******@TK2MSFTN GP09.phx.gbl...
Yes, you can. And as soon as you do that, you can no longer access that
column's value in the Grid to pass back to the data layer in order to have
it use a FindRows method to locate the corresponding row in the underlying DataTable to DELETE. Best alternative: set the column's width to zero,

but
that means creating another grid table style (because you can't get at the default one to manipulate just one column's attributes - another strange
restriction that Microsoft freely admits too in its online Help).

"Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
message news:eH******** ******@TK2MSFTN GP12.phx.gbl...
small remark on point 3

you can hide a column without using the styles...
myTable.Columns (colIdx).Column Mapping = MappingType.Hid den
"Fred Morrison" <fm*******@erol s.com> wrote in message
news:OY******** ******@TK2MSFTN GP11.phx.gbl...
> 1. No Columns collection.
> 2. No ability to easily synchronize the underlying DataTable of a

DataGrid
> when a row is deleted in the Grid. Once you sort (via the column

headers)
> all bets are off as to whether the current row index of the data grid
can
be
> used directly as the Rows index of the DataTable. This is
documented in the
> DataGrid Overview.
> 3. No way to access the default grid table style to make minor
changes to
> just one column (i.e., hide it or make it's width property zero).
Not even
> for read-only purposes (see #1).
> 4. No way to easily pick up the value of a hidden column in the Grid
(which
> has to be hidden using Data Layer techniques, not Presentation Layer
> techniques). You have to make some ASSumption about the relationship
of > grid columns to DataTable columns or use some nasty hard-coding that begs
> for future maintenance errors.
> 5. If you want to delete a row from the data grid in your
Presentation > Layer, you can't directly use the DeleteRow method of the grid (see #2 > above) without going into the Data Layer to FindRows the corresponding row
> in the datatable. Kind of kills the idea of separation of

Presentation > Layer, Business Layer and Data Layers if the Presentation Layer has
to know
> how to reach into a DataTable in order to know how to delete a row

in a > Presentation Layer control (grid).
>
> Is there a 3rd-party Grid control that does not suffer from these
> deficiencies?
>
>



Nov 20 '05 #7

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

Similar topics

0
842
by: Zulander | last post by:
Hi I am having trouble to add some property to my user control, this is what I have, and I don't know why that my properties are not showing in the Property gird. Thank you Imports System.ComponentModel Public Class Bone
0
956
by: squrel | last post by:
Hello All... I m getting this error in my project " Unable to locate record. verify that first column of view gird is unique" .. i have checked my gird and nothing wrong.. checked my database and tables, nothing is duplicate or repeated... when i double click on the record appearing in the gird this error will appear... the rest of my forms and...
3
5632
by: usha535140 | last post by:
Hi, Can we use Ajax RoundedCornersExtender control with AJax,tabContainer?
2
1523
sanjib65
by: sanjib65 | last post by:
I try to create a custom control that will say, Hello + ComputerUserName. I have added in my App_Code folder a WelcomeLabel.cs file: // WelcomeLabel.cs using System; using System.ComponentModel; using System.Security.Permissions; using System.Web; using System.Web.UI;
0
7817
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7738
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7833
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8119
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6482
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5322
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3759
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3771
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1082
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.