Data Dictionary App - Yikes!

Data Dictionary App - Yikes!

am 30.01.2008 18:31:03 von Rbrt

I am writing an application that is data dictionary driven - users will have
the ability to create tables and add fields to those tables, and other users
will be able to do data entry into these tables, view them, etc...

The problem is in writing the code for data entry and display. I have tried
FormView, GridView, Generic Repeater controls, etc. but have not been able to
find a way to dynamically add the necessary textboxes, what have you, when
the structure of the table and fields is not known beforehand. Everything I
have seen about these controls tells me that you have to explicitly define
controls at design time by specifying each object in a DIM command (VB).

This used to be very easy using Control Arrays but if I understand
correctly, control arrays are not supported in ASP.NET.

Any suggestions?

RE: Data Dictionary App - Yikes!

am 30.01.2008 20:45:01 von brucebarker

all controls in asp.net are dynamic and created at runtime. its trivial to
add them. in asp.net all container controls have a Controls collection you
can add new control to:


TextBox t = new TextBox();
t.Id = "text1";
myContainter.Controls.Add(t);

you might also want to look at the asp.net MVC toolkit which is a better
framework for this type of application. also look at iron python or iron ruby
which are also much better languages for this type of application then vb.net
or c#. The new dynamic binding controls were designed with these languages in
mind.

-- bruce (sqlwork.com)


"Rbrt" wrote:

> I am writing an application that is data dictionary driven - users will have
> the ability to create tables and add fields to those tables, and other users
> will be able to do data entry into these tables, view them, etc...
>
> The problem is in writing the code for data entry and display. I have tried
> FormView, GridView, Generic Repeater controls, etc. but have not been able to
> find a way to dynamically add the necessary textboxes, what have you, when
> the structure of the table and fields is not known beforehand. Everything I
> have seen about these controls tells me that you have to explicitly define
> controls at design time by specifying each object in a DIM command (VB).
>
> This used to be very easy using Control Arrays but if I understand
> correctly, control arrays are not supported in ASP.NET.
>
> Any suggestions?

RE: Data Dictionary App - Yikes!

am 30.01.2008 21:18:01 von Rbrt

Won't work. I want to create a Form to display the data from a database that
I do not know the structure of. So I do a "SELECT * from " & strTblName...

....and I get a datatable. Now I find out not only what the table's data
might be, but also its fields....

It's time to present that data ...

so...

"Textbox t = new textbox" is not going to help because I cannot say what t
is in runtime, which is when I discover what the table fields might be...

I need to be able to say at runtime...

Textbox (datatable.fields(x).name) = new TextBox()...

or ...

Textbox(x) = new textbox

or something similar....

"bruce barker" wrote:

> all controls in asp.net are dynamic and created at runtime. its trivial to
> add them. in asp.net all container controls have a Controls collection you
> can add new control to:
>
>
> TextBox t = new TextBox();
> t.Id = "text1";
> myContainter.Controls.Add(t);
>
> you might also want to look at the asp.net MVC toolkit which is a better
> framework for this type of application. also look at iron python or iron ruby
> which are also much better languages for this type of application then vb.net
> or c#. The new dynamic binding controls were designed with these languages in
> mind.
>
> -- bruce (sqlwork.com)
>
>
> "Rbrt" wrote:
>
> > I am writing an application that is data dictionary driven - users will have
> > the ability to create tables and add fields to those tables, and other users
> > will be able to do data entry into these tables, view them, etc...
> >
> > The problem is in writing the code for data entry and display. I have tried
> > FormView, GridView, Generic Repeater controls, etc. but have not been able to
> > find a way to dynamically add the necessary textboxes, what have you, when
> > the structure of the table and fields is not known beforehand. Everything I
> > have seen about these controls tells me that you have to explicitly define
> > controls at design time by specifying each object in a DIM command (VB).
> >
> > This used to be very easy using Control Arrays but if I understand
> > correctly, control arrays are not supported in ASP.NET.
> >
> > Any suggestions?

RE: Data Dictionary App - Yikes!

am 30.01.2008 21:47:00 von pbromberg

I don't see why you cannot do this. You just need to get the syntax correct.
For example (pseudocode, untested):

foreach( DataRow row in myDataTable.Rows)
{
foreach DataColumn col in myDataTable.Columns)
{
TextBox t = new TextBox();
t.ID = col.ColumnName;
t.Text = (string)row[col.ColumnName];
// add "t" to container control here, handle positioning
}


}
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


"Rbrt" wrote:

> Won't work. I want to create a Form to display the data from a database that
> I do not know the structure of. So I do a "SELECT * from " & strTblName...
>
> ...and I get a datatable. Now I find out not only what the table's data
> might be, but also its fields....
>
> It's time to present that data ...
>
> so...
>
> "Textbox t = new textbox" is not going to help because I cannot say what t
> is in runtime, which is when I discover what the table fields might be...
>
> I need to be able to say at runtime...
>
> Textbox (datatable.fields(x).name) = new TextBox()...
>
> or ...
>
> Textbox(x) = new textbox
>
> or something similar....
>
> "bruce barker" wrote:
>
> > all controls in asp.net are dynamic and created at runtime. its trivial to
> > add them. in asp.net all container controls have a Controls collection you
> > can add new control to:
> >
> >
> > TextBox t = new TextBox();
> > t.Id = "text1";
> > myContainter.Controls.Add(t);
> >
> > you might also want to look at the asp.net MVC toolkit which is a better
> > framework for this type of application. also look at iron python or iron ruby
> > which are also much better languages for this type of application then vb.net
> > or c#. The new dynamic binding controls were designed with these languages in
> > mind.
> >
> > -- bruce (sqlwork.com)
> >
> >
> > "Rbrt" wrote:
> >
> > > I am writing an application that is data dictionary driven - users will have
> > > the ability to create tables and add fields to those tables, and other users
> > > will be able to do data entry into these tables, view them, etc...
> > >
> > > The problem is in writing the code for data entry and display. I have tried
> > > FormView, GridView, Generic Repeater controls, etc. but have not been able to
> > > find a way to dynamically add the necessary textboxes, what have you, when
> > > the structure of the table and fields is not known beforehand. Everything I
> > > have seen about these controls tells me that you have to explicitly define
> > > controls at design time by specifying each object in a DIM command (VB).
> > >
> > > This used to be very easy using Control Arrays but if I understand
> > > correctly, control arrays are not supported in ASP.NET.
> > >
> > > Any suggestions?

RE: Data Dictionary App - Yikes!

am 30.01.2008 22:05:04 von Rbrt

The problem comes when you want to add the control to a PlaceHolder. You can
have only one TextBox t, right?

"Peter Bromberg [C# MVP]" wrote:

> I don't see why you cannot do this. You just need to get the syntax correct.
> For example (pseudocode, untested):
>
> foreach( DataRow row in myDataTable.Rows)
> {
> foreach DataColumn col in myDataTable.Columns)
> {
> TextBox t = new TextBox();
> t.ID = col.ColumnName;
> t.Text = (string)row[col.ColumnName];
> // add "t" to container control here, handle positioning
> }
>
>
> }
> -- Peter
> Site: http://www.eggheadcafe.com
> UnBlog: http://petesbloggerama.blogspot.com
> MetaFinder: http://www.blogmetafinder.com
>
>
> "Rbrt" wrote:
>
> > Won't work. I want to create a Form to display the data from a database that
> > I do not know the structure of. So I do a "SELECT * from " & strTblName...
> >
> > ...and I get a datatable. Now I find out not only what the table's data
> > might be, but also its fields....
> >
> > It's time to present that data ...
> >
> > so...
> >
> > "Textbox t = new textbox" is not going to help because I cannot say what t
> > is in runtime, which is when I discover what the table fields might be...
> >
> > I need to be able to say at runtime...
> >
> > Textbox (datatable.fields(x).name) = new TextBox()...
> >
> > or ...
> >
> > Textbox(x) = new textbox
> >
> > or something similar....
> >
> > "bruce barker" wrote:
> >
> > > all controls in asp.net are dynamic and created at runtime. its trivial to
> > > add them. in asp.net all container controls have a Controls collection you
> > > can add new control to:
> > >
> > >
> > > TextBox t = new TextBox();
> > > t.Id = "text1";
> > > myContainter.Controls.Add(t);
> > >
> > > you might also want to look at the asp.net MVC toolkit which is a better
> > > framework for this type of application. also look at iron python or iron ruby
> > > which are also much better languages for this type of application then vb.net
> > > or c#. The new dynamic binding controls were designed with these languages in
> > > mind.
> > >
> > > -- bruce (sqlwork.com)
> > >
> > >
> > > "Rbrt" wrote:
> > >
> > > > I am writing an application that is data dictionary driven - users will have
> > > > the ability to create tables and add fields to those tables, and other users
> > > > will be able to do data entry into these tables, view them, etc...
> > > >
> > > > The problem is in writing the code for data entry and display. I have tried
> > > > FormView, GridView, Generic Repeater controls, etc. but have not been able to
> > > > find a way to dynamically add the necessary textboxes, what have you, when
> > > > the structure of the table and fields is not known beforehand. Everything I
> > > > have seen about these controls tells me that you have to explicitly define
> > > > controls at design time by specifying each object in a DIM command (VB).
> > > >
> > > > This used to be very easy using Control Arrays but if I understand
> > > > correctly, control arrays are not supported in ASP.NET.
> > > >
> > > > Any suggestions?

RE: Data Dictionary App - Yikes!

am 31.01.2008 12:36:00 von Rbrt

Answering my own question... I've found this MSDN article which might be
useful and I am trying it out now...

http://msdn2.microsoft.com/en-us/library/aa289500(VS.71).asp x

"Rbrt" wrote:

> I am writing an application that is data dictionary driven - users will have
> the ability to create tables and add fields to those tables, and other users
> will be able to do data entry into these tables, view them, etc...
>
> The problem is in writing the code for data entry and display. I have tried
> FormView, GridView, Generic Repeater controls, etc. but have not been able to
> find a way to dynamically add the necessary textboxes, what have you, when
> the structure of the table and fields is not known beforehand. Everything I
> have seen about these controls tells me that you have to explicitly define
> controls at design time by specifying each object in a DIM command (VB).
>
> This used to be very easy using Control Arrays but if I understand
> correctly, control arrays are not supported in ASP.NET.
>
> Any suggestions?