E
Evert Wiesenekker
When I started learning ASP.NET two years ago I created my pages in a
visually oriented way, eg by dragging and dropping controls on the
page. I mainly used DataGrid's binding their data to custom made SQL
Server stored procedures. To get more binding control I later developed
template columns for my DataGrid's. This works very well.
Now I just started a very small project, which is too small to use SQL
Server for. For this project I decided to use another approach:
designing custom classes (the OO-way). So I designed for example a
Person class, an Address clas ect. For storage I use XML serializtion.
This works amazingly simple, even my complex classes, which contain
other collections of classes, serialize perfectly! So I was very happy
with my Object model and switched to the toolbar and found out the
binding to Visual Controls seems not very clear to me. How do I bind in
a simple manner my custom classes to Visual controls. It seems to me me
I cannot do a simple databind, because the ouput needs to be generated
based on the value of some poperties. So for example suppose I have a
Shop which has a collection of Products, I only want the Repeater
control (or whatever visual control) to display its products which are
available (eg some property of a product instance has a DateTime
greater than the current date).
Now I saw a solution from a collegue of mine. He uses the Table object
and dynamically creates the table: he foreaches over the custom
collection and for every instance he creates a TableRow with the
apporiate TableCells. I found it a very simple solution giving a lot of
flexibility (and code..). When I used the DataGrid's OnDataBinding
event in combination with the FindControl method a little awkward.
Now I am using his solution and want to know if this is the way to go
for custom classes. Because I have the eerie feeling this can be done
in a more advanced way.
Thanks for any comments!
Evert Wiesenekker
By the way I am using now VS 2005
visually oriented way, eg by dragging and dropping controls on the
page. I mainly used DataGrid's binding their data to custom made SQL
Server stored procedures. To get more binding control I later developed
template columns for my DataGrid's. This works very well.
Now I just started a very small project, which is too small to use SQL
Server for. For this project I decided to use another approach:
designing custom classes (the OO-way). So I designed for example a
Person class, an Address clas ect. For storage I use XML serializtion.
This works amazingly simple, even my complex classes, which contain
other collections of classes, serialize perfectly! So I was very happy
with my Object model and switched to the toolbar and found out the
binding to Visual Controls seems not very clear to me. How do I bind in
a simple manner my custom classes to Visual controls. It seems to me me
I cannot do a simple databind, because the ouput needs to be generated
based on the value of some poperties. So for example suppose I have a
Shop which has a collection of Products, I only want the Repeater
control (or whatever visual control) to display its products which are
available (eg some property of a product instance has a DateTime
greater than the current date).
Now I saw a solution from a collegue of mine. He uses the Table object
and dynamically creates the table: he foreaches over the custom
collection and for every instance he creates a TableRow with the
apporiate TableCells. I found it a very simple solution giving a lot of
flexibility (and code..). When I used the DataGrid's OnDataBinding
event in combination with the FindControl method a little awkward.
Now I am using his solution and want to know if this is the way to go
for custom classes. Because I have the eerie feeling this can be done
in a more advanced way.
Thanks for any comments!
Evert Wiesenekker
By the way I am using now VS 2005