Click here to Skip to main content
15,889,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
requirement :
1. Create Dynamic Controls from Database (Db has all Info) Even controls must be populate with all values.
2. Don't want to postback and remove page load.
3. wants to Use some service and return type I am expecting as Controls with all values (means if it is drop down It should bind with values) and It should populate on ASP.Net page ....

or looking some easiest way to achieve this requirement ..

thanks in Advance

Blow code is working and achieving something but don't want to interact with Database...here I am communicating two times wit DB..Firstly for Controls and then for Binding the controls..

wants to remove this...

C#
int ObjectType_Id = 10000939;
           int UserID = 46855;
           DataSet dsDropDownItems = new DataSet();
           string Permission = "write";
            //(2501,46855,'write')
           List<dynfields> DynFieldsOnPageList = new List<dynfields>();
           BLLDynFields bllDynField = new BLLDynFields();
           ContentPlaceHolder content = (ContentPlaceHolder)this.Master.FindControl("MainContent");
           DynFieldsOnPageList = bllDynField.GetDynFieldsOnPage(ObjectType_Id, UserID, Permission);

           if ((DynFieldsOnPageList != null))
           {

               for (int i = 0; i < DynFieldsOnPageList.Count; i++) // Loop with for.
               {
                   switch (DynFieldsOnPageList[i].Widget)
                   {
                       case "textdate":
                           break;
                       case "text":
                           Label lbl1 = new Label();
                           lbl1.Text = DynFieldsOnPageList[i].PrettyName;
                           TextBox TextBox1 = new TextBox();
                           TextBox1.ID = DynFieldsOnPageList[i].AttributeName;
                           //TextBox1.Style["Position"] = "Absolute";
                           //TextBox1.Style["Top"] = "25px";
                           //TextBox1.Style["Left"] = "100px";
                           //content.Controls.Add(lbl1);
                           //content.Controls.Add(TextBox1);

                           break;
                       case "checkbox":

                           break;
                       case "richtext":

                           break;
                       case "im_cost_center_tree":

                           break;
                       case "textarea":

                           break;
                       case "select":

                           break;
                       case "date":

                           break;
                       case "ampmFragment":

                           break;
                       case "generic_sql":

                           Label lbl = new Label();
                           lbl.Text = DynFieldsOnPageList[i].PrettyName;
                           DropDownList ddl = new DropDownList();
                           ddl.ID = DynFieldsOnPageList[i].AttributeName;

                           string SQLQuery = DynFieldsOnPageList[i].SqlParameter;
                           char[] delimiterChars = { '{', '}' };
                           string[] FinalQuery = SQLQuery.Split(delimiterChars);

                           dsDropDownItems = bllDynField.FillDropDownRuntime(FinalQuery[3]);
                           ddl.DataSource = dsDropDownItems.Tables[0];
                           ddl.DataTextField = dsDropDownItems.Tables[0].Columns[0].ToString();
                           ddl.DataValueField = dsDropDownItems.Tables[0].Columns[1].ToString();
                           ddl.DataBind();
                           ddl.AutoPostBack = true;
                           ddl.Style.Add("margin", "20px");
                           ddl.Style.Add("margin-right", "20px");
                           Table tb = new Table();
                           TableRow tr = new TableRow();
                           TableCell td = new TableCell();
                           TableCell td1 = new TableCell();


                           td.Controls.Add(lbl);
                           td1.Controls.Add(ddl);
                           tr.Cells.Add(td);
                           tr.Cells.Add(td1);
                           tb.Rows.Add(tr);

                           content.Controls.Add(lbl);
                           content.Controls.Add(ddl);
                           content.Controls.Add(tb);

                           pnlDynamiccontrol.Controls.Add(tb);
                           break;
                       case "radio":

                           break;

                   }


               }
Posted
Updated 30-Sep-15 10:37am
v2
Comments
ZurdoDev 30-Sep-15 7:37am    
What exactly is your question?

1 solution

All Kind of ASP.Net .like drop down ,text box,Radio Button etc..and all information I have stored in Database so On Run time I have to find particular controls on specific page...

all things are mapped in Database ...I need to display these controls on page without connecting multiple times to database..
I am thinking about Ajax method
or Services etc Kindly suggest ..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900