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
- foreach (ListItem li in CheckBoxListmst.Items)
- {
- if (li.Selected == true)
- {
- //code added to fetch dropdownlist
- setting = ConfigurationManager.ConnectionStrings["StyleSearchConnectionString"];
- if (setting != null)
- {
- conn = new SqlConnection(setting.ConnectionString);
- cmd = new SqlCommand("Search_display");
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.Add("@cateid", SqlDbType.VarChar);
- cmd.Parameters["@cateid"].Value = li.Text.ToString();
- conn.Open();
- cmd.Connection = conn;
- try
- {
- // added controls
- Label label = new Label();
- DropDownList dropdownlist = new DropDownList();
- label.ID = "label" + li.Text;
- dropdownlist.ID = "dropdownlist" + li.Text;
- label.Text = li.Text;
- rdr = cmd.ExecuteReader();
- while (rdr.Read())
- {
- ListItem ld = new ListItem();
- ld.Text = rdr["disp"].ToString();
- ld.Value = rdr["mstid"].ToString();
- dropdownlist.Items.Add(ld);
- }
- PlaceHolder1.Controls.Add(label);
- PlaceHolder1.Controls.Add(dropdownlist);
- Response.Write("<BR >");
- //added controls end
- }
- catch (SqlException ex)
- {
- }
thanks