Click here to Skip to main content
15,899,632 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have created a two dynamic control & added in placeholder one by one. But I doesn't able to set its according to need.

My Code giving me output like :

C#
Color
Size
Material
MadeIn

Blue Red Green,
Yellow Black Violet
38 40 42
44 46 XL
XS 3XL L
Cotton Synthetic Nylon
USA UK INDIA
France Germany UAE


But I want Output Like This :
XML
Color :
Blue Red Green,
Yellow Black Violet

Size :
38 40 42
44 46 XL
XS 3XL L

Material :
Cotton Synthetic Nylon

MadeIn :
USA UK INDIA
France Germany UAE


Kindly see my Code below :

C#
private void bind_chk()
   {
       string queries = "select distinct varient from tbl_ProductVariety_Value";
       SqlDataAdapter da = new SqlDataAdapter(queries, new CommonClass().connection());
       DataTable data = new DataTable();
       da.Fill(data);
       if (data.Rows.Count > 0)
       {
           for (int im = 0; im < data.Rows.Count; im++)
           {
               string query = "select prd_vrtyvalue_id,varient_value from tbl_ProductVariety_Value  where varient='" + data.Rows[im]["varient"].ToString() + "' " +
                                         " order by varient_value asc ";
               DataTable abc = new DataTable();
               SqlDataAdapter ada = new SqlDataAdapter(query, new CommonClass().connection());
               ada.Fill(abc);

               Label lbl = new Label();
               lbl.Text = data.Rows[im]["varient"].ToString() + "<br/><br/>";
               lbl.ForeColor = System.Drawing.Color.Blue;
               PlaceHolder2.Controls.Add(lbl);

               Label1.Text = data.Rows[im]["varient"].ToString();

               CheckBoxList ChkboxList = new CheckBoxList();
               ChkboxList.ID = "Chkbox"+im;
               for (int i = 0; i < abc.Rows.Count; i++)
               {
                   ChkboxList.Items.Add(new ListItem(abc.Rows[i]["varient_value"].ToString(), abc.Rows[i]["prd_vrtyvalue_id"].ToString()));
               }
               ChkboxList.RepeatColumns = 3;
               PlaceHolder1.Controls.Add(ChkboxList);
               Response.Write("");
           }
       }
       else
       {
           ScriptManager.RegisterStartupScript(this, GetType(), "error", "alert('0 result found '" + Label1.Text + "' !');", true);
       }
   }


I really appreciate any suggestion regarding this :)
Posted
Updated 18-Mar-13 22:25pm
v3

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