I have a one dropdownlist and checkbox items. How can i make when i keep selected items when change dropdown listitem.
- protected void ddlList_SelectedIndexChanged(object sender, EventArgs e)
- {
- ddlList.AppendDataBoundItems = true;
- StringBuilder builder = new StringBuilder();
- string sqlQueryOcc = "";
- sqlQueryOcc += " select child.CODE,child.TITLE,child.PARENT_CODE,child.YEARS, parent.INDUS_CAT_NAME";
- sqlQueryOcc += " from SALARY_INDS_OCCNAME as parent ";
- sqlQueryOcc += " inner join dbo.SALARY_INDS_OCCSUBNAME as child ";
- sqlQueryOcc += " on parent.INDUS_CAT_CODE = child.PARENT_CODE";
- sqlQueryOcc += " where child.PARENT_CODE = '" + ddlList.SelectedValue + "' and child.YEARS = '" + ddlYear.SelectedValue + "'";
- sqlQueryOcc += " group by child.CODE,child.TITLE , child.PARENT_CODE ,child.YEARS, parent.INDUS_CAT_NAME";
- sqlQueryOcc += " having count(*)>1";
- sqlQueryOcc += " order by child.PARENT_CODE asc";
-
- seledItems = ConvertLib.ToStr(Request.Form["sel_items[]"], string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- HiddenField1.Value = String.Join(",", seledItems);
- using (SqlCommand cmd = new SqlCommand(sqlQueryOcc))
- {
- cmd.CommandType = CommandType.Text;
- cmd.Connection = conn;
- conn.Open();
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- DataTable dt = new DataTable();
- da.Fill(dt);
-
-
- foreach (DataRow row in dt.Rows)
- {
- builder.AppendFormat("<li><span><input type='checkbox' name='sel_items[]' value='{0}-{3}'{2} /></span>{1}</li>", row["CODE"].ToString(), row["TITLE"].ToString(), this.IsChecked(row["CODE"].ToString(), seledItems), row["PARENT_CODE"].ToString());
- }
- conn.Close();
-
- this.occList.Text = builder.ToString();
- }
- }
For ex: DropdownList first item Fruit, when i was select fruit will be show apple, banana, orange, then i select apple and banana. After selected thats change dropdownlist second item for ex: Computer. then when i was select computer will be show keyboard, monitor, mouse, camera etc. and will be select monitor and keyboard. Then i done this submit this event need to show apple, banana, monitor and keyboard.
how can i make it ?