473,480 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataGrid.Binding()

Hi,

If anybody needs to show some data retrieved from the database table, what
method is more preferrable?

1. DataSet ds = ...;
DataGrid.Data.Source.ds;
DataGrid.Bind();

2. Write a custom object, fill it with the DataSet data and ÅÒÕÔ try to bind
the DataGrid or DataTable and this custom object?

I usually don't allow users to change anything irectly in the DataGrid, but
I allow to select a row and then show a set of TextBoxes, DropDown lists
etc. to correct/enter data. Is it a good approach or it's better to allow
userworking with the DataGrid directly and then Update this DataSet or
whatever?

Thanks,
Dmitri

Nov 18 '05 #1
3 1643
Dmitri,
It really depends on what you are doing. I, for instance, steer away
from the DataSet object. I usually don't have a need for its features. A
dataset is very useful if you need to have several tables linked together in
a parent/child relationship or in some other fashion. When I need to bind
data, I find that I have a single set of data. If I were to use the dataset
for this, I would be creating an object with more overhead than I need. I
usually have a custom object for every entity that I work with, so I would
just use a datareader from the database to create a collection of these
objects. If your data is very simple, you could just create an array of
strings to which to bind. Bindable controls can bind to any object that has
primitive public properties such as string and int.

Also, in question number 2, you are confusing a web control with an ADO.NET
object. You cannot bind a DataTable with a custom object. A DataTable is a
container object commonly used within a DataSet. A Datagrid can be bound TO
a DataTable or other custom object or simply an array. Check out the SDK
documentation on databinding.

Best regards,
Jeffrey Palermo

"Just D" <no@spam.please> wrote in message
news:yYZMc.11217$BX.10688@lakeread08...
Hi,

If anybody needs to show some data retrieved from the database table, what
method is more preferrable?

1. DataSet ds = ...;
DataGrid.Data.Source.ds;
DataGrid.Bind();

2. Write a custom object, fill it with the DataSet data and ÅÒÕÔ try to bind the DataGrid or DataTable and this custom object?

I usually don't allow users to change anything irectly in the DataGrid, but I allow to select a row and then show a set of TextBoxes, DropDown lists
etc. to correct/enter data. Is it a good approach or it's better to allow
userworking with the DataGrid directly and then Update this DataSet or
whatever?

Thanks,
Dmitri

Nov 18 '05 #2
Hi Jeffry,
Also, in question number 2, you are confusing a web control with an
ADO.NET
object. You cannot bind a DataTable with a custom object. A DataTable is
a
container object commonly used within a DataSet. A Datagrid can be bound
TO
a DataTable or other custom object or simply an array. Check out the SDK
documentation on databinding.


You know, maybe the second part of the question was not correct. Thanks that
you corrected me.

What about the first question? If you receive data from a few database
tables using subqueries, JOIN, many other tricks, then do you parse this
information to your custom objects loading the whole data into your own
object and then deleting the original DataSet? Ok, I can imagine that, but
if you need to save the changes, made by user, then you need to compare what
has been changes, so you need flags in every sub object to detect if this
data is dirty and finally write this data? What do you think if you use a
database view to retrieve this complex data instead and save data back to
this view? In this case you could use the same DataSet to show and save a
changed data and use DataAdapter.Update() any headache. Is it good or bad?
Or I don't see something obvious? Maybe the custom objects are always
better?

Thanks,
Dmitri

Nov 18 '05 #3
Dmitri,
In the case that you just described, it would be very easy to use a
dataset to automate your updates back to the database, so you can use that
method.

Best regards,
Jeffrey Palermo

"Just D" <no@spam.please> wrote in message
news:XU_Mc.11245$BX.10412@lakeread08...
Hi Jeffry,
Also, in question number 2, you are confusing a web control with an
ADO.NET
object. You cannot bind a DataTable with a custom object. A DataTable is a
container object commonly used within a DataSet. A Datagrid can be bound TO
a DataTable or other custom object or simply an array. Check out the SDK documentation on databinding.
You know, maybe the second part of the question was not correct. Thanks

that you corrected me.

What about the first question? If you receive data from a few database
tables using subqueries, JOIN, many other tricks, then do you parse this
information to your custom objects loading the whole data into your own
object and then deleting the original DataSet? Ok, I can imagine that, but
if you need to save the changes, made by user, then you need to compare what has been changes, so you need flags in every sub object to detect if this
data is dirty and finally write this data? What do you think if you use a
database view to retrieve this complex data instead and save data back to
this view? In this case you could use the same DataSet to show and save a
changed data and use DataAdapter.Update() any headache. Is it good or bad?
Or I don't see something obvious? Maybe the custom objects are always
better?

Thanks,
Dmitri

Nov 18 '05 #4

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

Similar topics

6
18265
by: Shivang | last post by:
Hello Everybody, I am using Datagrid in VB.net. I don't want the auto generation of rows in the datagrid (last row shouldnt be the new row with empty values)..in addition to this the datagrid...
0
1825
by: Tom Hughes | last post by:
I want to change one field of all selected rows to a provided value. Problem 1 I am using the Binding Manager Base to bind the datagrid to the appropriate dataTable as recommended by KB817247....
5
2561
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...
4
2816
by: Steve B. | last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's reflect the contents of the grid cells. Sorting of columns (both thru VS and programmatically) work fine except, when the...
0
3476
by: Dave | last post by:
Tried posting in the Winform Forum without much luck, so posting here... After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is...
6
3298
by: Alpha | last post by:
I have several textboxes that I need to chang the text when the selection row is changed in a datagrid. I have the following code. This textbox displayes the initial selection but when I click on...
3
4885
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
5
2277
by: Brad Shook | last post by:
I am trying to bind one column of a datagrid to a seperate textbox and the rest of the fields to a datagrid. the comments are too large to fit in a datagrid so I created a textbox below the...
17
2727
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
2
6556
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
6908
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...
0
7048
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
7088
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...
1
6741
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...
0
6956
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
5342
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,...
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
183
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...

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.