471,092 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

how to align control in palceholder control

Dear All,
I am making web application using Asp.net C#(Visual Studio2005).
I have checkboxlist(which is populated by all the master filed like category , subcategory ,customer , etc ). Now based on selection I generates web control label (to name the field) and dropdownlistbox (which is filled by code and its description).

My problem is all controls comes one after other. I would like label then dropdownlist in a single line. That custlabel and its dropdownlist comes in one line then next say categorylabel and its dropdownlistbox should align in next line and inbetween them one free line .

My code is
Expand|Select|Wrap|Line Numbers
  1.   foreach (ListItem li in CheckBoxListmst.Items)
  2.         {
  3.             if (li.Selected == true)
  4.             {
  5.                 //code added to fetch dropdownlist
  6.                 setting =               ConfigurationManager.ConnectionStrings["StyleSearchConnectionString"];
  7.                 if (setting != null)
  8.                 {
  9.                     conn = new SqlConnection(setting.ConnectionString);
  10.                     cmd = new SqlCommand("Search_display");
  11.                     cmd.CommandType = CommandType.StoredProcedure;
  12.                     cmd.Parameters.Add("@cateid", SqlDbType.VarChar);
  13.                     cmd.Parameters["@cateid"].Value = li.Text.ToString();
  14.  
  15.                     conn.Open();
  16.                     cmd.Connection = conn;
  17.                     try
  18.                     {
  19.                         // added controls
  20.                         Label label = new Label();
  21.                         DropDownList dropdownlist = new DropDownList();
  22.                         label.ID = "label" + li.Text;
  23.                         dropdownlist.ID = "dropdownlist" + li.Text;
  24.                         label.Text = li.Text;
  25.                         rdr = cmd.ExecuteReader();
  26.                         while (rdr.Read())
  27.                         {
  28.                             ListItem ld = new ListItem();
  29.  
  30.                             ld.Text = rdr["disp"].ToString();
  31.                             ld.Value = rdr["mstid"].ToString();
  32.                             dropdownlist.Items.Add(ld);
  33.  
  34.  
  35.                         }
  36.                         PlaceHolder1.Controls.Add(label);
  37.                         PlaceHolder1.Controls.Add(dropdownlist);
  38.  
  39.  
  40.                         Response.Write("<BR >");
  41.                         //added controls end
  42.  
  43.                     }
  44.  
  45.                     catch (SqlException ex)
  46.                     {
  47.                     }
  48.  
  49.  
Please Guide me or atleast give some help full link.
thanks
Jul 23 '07 #1
1 1517
Frinavale
9,735 Expert Mod 8TB
Dear All,
I am making web application using Asp.net C#(Visual Studio2005).
I have checkboxlist(which is populated by all the master filed like category , subcategory ,customer , etc ). Now based on selection I generates web control label (to name the field) and dropdownlistbox (which is filled by code and its description).

My problem is all controls comes one after other. I would like label then dropdownlist in a single line. That custlabel and its dropdownlist comes in one line then next say categorylabel and its dropdownlistbox should align in next line and inbetween them one free line .

My code is ...
Please Guide me or atleast give some help full link.
thanks
Most asp.net controls have a CssClass property. When you create the DropDownList or Label or other web control, you can assign the control a CssClass.

All you have to do is create the CSS file, add the class that outlines how the control should be displayed, reference the CSS file in your aspx page, and assign the controls the appropriate class.

I'd look into how to use CSS.

-Frinny
Jul 23 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Mikko Rantalainen | last post: by
3 posts views Thread by VB Programmer | last post: by
2 posts views Thread by Jim McGivney | last post: by
14 posts views Thread by artifact.one | last post: by
2 posts views Thread by swapna_munukoti | last post: by
1 post views Thread by ShayHk | last post: by
40 posts views Thread by maya | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.