put it in some namespace - herewith Utils
put all the methods so that you will pass the parameters by reference to them - all the parameters - gui controls , datasets , etc.
so the classs will look like this:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Utils {
//comm -- /
//comm -- / Summary description for Utils.GUIBuilder
//comm -- /
public class GUIGenerator
{
public void GenerateSomething (ref Panel panel_obj , ref DataSet ds )
{
//iterate over a dataset with param values :
foreach (DataTable dt in ds.Tables) //comm -- we have only one table
{
Utils.Debugger.WriteIf ( "The name of the table is " + dt.TableName );
foreach (DataRow dr in dt.Rows)
{
//comm -- this is complete mess - hint enable css colors debugging to see the boxes
//comm -- debug Debug.WriteLine ( "dr[0] is " + dr [ 0 ] );
//comm -- debug Debug.WriteLine ( "dr[1] is " + dr [ 1 ] );
//comm -- take the NameOf the control
string nameOfControl = System.Convert.ToString(dr [ 0 ]);
//comm -- take the Name of the Type as string
string typeOfControl = System.Convert.ToString ( dr [ 1 ] );
Panel glb_panel = new Panel ( );
glb_panel.ID = nameOfControl + "_glb";
glb_panel.ToolTip = "fill in here the " + nameOfControl;
HtmlInputCheckBox cb = new HtmlInputCheckBox ( );
cb.ID = nameOfControl + "_cb";
cb.Checked = (bool)dr [ 2 ];
glb_panel.Controls.Add ( cb );
Label lb = new Label ( );
lb.Text = nameOfControl;
glb_panel.Controls.Add ( lb );
glb_panel.CssClass = "glb";
glb_panel.Wrap = true;
glb_panel.Visible = true;
if ((string)dr [ 3 ] != null)
{
filledValue = (string)dr [ 3 ]; //comm -- the fourth columns contains the values of the controls
}
else
{
filledValue = "";
}
//string filledValue = "fakeValue";
this.GenerateFilledControl ( ref nameOfControl, ref typeOfControl, ref glb_panel , ref filledValue);
panel_obj.ContentTemplateContainer.Controls.Add ( glb_panel );
/*
DropDownList drop = new DropDownList ( );
drop.Items.Add ( "OR" );
drop.Items.Add ( "AND" );
drop.Items.Add ( "LIKE" );
drop.ID = dt.ToString ( ) + "row" + rowNum; //comm -- mark this row number
drop.CssClass = "connector_class";
panel_obj.ContentTemplateContainer.Controls.Add ( drop );
*/
} //eof foreach2
} //eof foreach1
} //eof method
} //eof class GUIGenerator
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!