I want to generate my UI's from using metadata. Should I use custom server controls or do I need something else? I want to generate these UI's for my CRUD operations only. thanks.
Are you generating the entire ASPX page on the fly, or dynamically creating controls within an existing web page?
You can create each UI dynamically quite easily using existing controls. Assuming you have enough meta data information, you can set max text lengths, allowed list items, etc. You can use Custom Web Controls as the main block
for these processes.
If you are doing something more off the wall, you might need to go to custom web controls, where you can write your own, or extend the existing controls quite easily. I have written a whole suite of customised controls that
implement certain interfaces to manage particular kinds of data (sorry this is a bit vague, but its commercially confidential at present).
I want to generate 4 screens. ------------------------------------ 1.Create..New 2.Read...Select 3.Update...Edit 4.Delete...... Case page will have its own attributeTypes ,Company page will have its own attribute types. Do really need custom web server controls
or can I solve this problem with System.CodeDom? The part that I am confused if How do I do this if i have to bind the UI to my objects. thanks anyway
The problem you might run into is having to create a dynamic page at run time, that is, both the ASPX file and a supporting DLL from a graph. rather than approach the problem from some compllex technical viewpoint, lets aproach
this more simply in order to get an example going.
Start with just one table that has some columns - It doesn't matter what they are for now. It is a simple matter to get the data using a number of different data providers, whether in the ASPX or code files. We can get the
data as a data table, iterate the columns to get information about type, and then display as well edit, delete, or add new rows. Since the column details in the table tell us about the database table, this is a useful start for discussion.
The example below uses nothing fancy, it simply gets the information from any table you care to supply the name of, and displays the column names, type, and the first ten rows of data (uses a Northwind connection, but you could
use any database you want).
Have a look and think whether this simple approach might fulfil your needs
<%@
Page Language="C#" %>
<%@
Import Namespace="System.Data" %>
<!
DOCTYPE
html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
erdsah88
Contributor
3453 Points
930 Posts
Need help in run time screens.
Jan 02, 2006 04:43 PM|LINK
sbyard
Contributor
5891 Points
1196 Posts
Re: Need help in run time screens.
Jan 02, 2006 07:23 PM|LINK
A wide ranging question.
Are you generating the entire ASPX page on the fly, or dynamically creating controls within an existing web page?
You can create each UI dynamically quite easily using existing controls. Assuming you have enough meta data information, you can set max text lengths, allowed list items, etc. You can use Custom Web Controls as the main block for these processes.
If you are doing something more off the wall, you might need to go to custom web controls, where you can write your own, or extend the existing controls quite easily. I have written a whole suite of customised controls that implement certain interfaces to manage particular kinds of data (sorry this is a bit vague, but its commercially confidential at present).
erdsah88
Contributor
3453 Points
930 Posts
Re: Need help in run time screens.
Jan 02, 2006 09:51 PM|LINK
sbyard
Contributor
5891 Points
1196 Posts
Re: Need help in run time screens.
Jan 03, 2006 11:37 AM|LINK
The problem you might run into is having to create a dynamic page at run time, that is, both the ASPX file and a supporting DLL from a graph. rather than approach the problem from some compllex technical viewpoint, lets aproach this more simply in order to get an example going.
Start with just one table that has some columns - It doesn't matter what they are for now. It is a simple matter to get the data using a number of different data providers, whether in the ASPX or code files. We can get the data as a data table, iterate the columns to get information about type, and then display as well edit, delete, or add new rows. Since the column details in the table tell us about the database table, this is a useful start for discussion.
The example below uses nothing fancy, it simply gets the information from any table you care to supply the name of, and displays the column names, type, and the first ten rows of data (uses a Northwind connection, but you could use any database you want).
Have a look and think whether this simple approach might fulfil your needs
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><
script runat="server">protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// get the data as a data table
DataView dv = ds.Select(new DataSourceSelectArguments()) as DataView;
DataTable dt = dv.ToTable();
// create an ASPX table to render
Table t = new Table();
pnlData.Controls.Add(t);
// Add table header row of column types
TableHeaderRow thr = new TableHeaderRow();
t.Rows.Add(thr);
foreach (DataColumn dc in dt.Columns)
{
TableHeaderCell thc = new TableHeaderCell();
thc.Text = dc.ColumnName + ". Type=" + dc.DataType.Name;
thr.Cells.Add(thc);
}
// add the data from the rows
foreach (DataRow dr in dt.Rows)
{
TableRow tr = new TableRow();
t.Rows.Add(tr);
// add column data to the row
for (int index = 0; index < dt.Columns.Count; index++)
{
TableCell tc = new TableCell();
tc.Text = dr[index].ToString();
tr.Cells.Add(tc);
}
}
}
}
</
script><
html xmlns="http://www.w3.org/1999/xhtml"><
head runat="server"><title>Dynamic Data</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Panel ID="pnlData" runat="server" />
<asp:SqlDataSource ID="ds" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT Top 10 * FROM [Products]" />
</form>
</body>
</html>
erdsah88
Contributor
3453 Points
930 Posts
Re: Need help in run time screens.
Jan 03, 2006 04:39 PM|LINK
sbyard
Contributor
5891 Points
1196 Posts
Re: Need help in run time screens.
Jan 03, 2006 06:29 PM|LINK
Most approaches will be fine for your needs
The one above is the simplest open approach and uses no special classes
If you want to design a process to to create your own classes, then the implementation can be simpler, but the code behind more complex.
Your call
erdsah88
Contributor
3453 Points
930 Posts
Re: Need help in run time screens.
Jan 04, 2006 05:38 AM|LINK