Note that there are some explanatory texts on larger screens.

plurals
  1. POSession for single value data is getting from database and for double value data is not coming
    text
    copied!<p>This is my code</p> <pre><code>using (SqlCommand cmd = new SqlCommand("select * from Products where cast(ProductID as nvarchar(100)) in ('" + Session["Products"] + "')", con)) { con.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { customers.Add(new ProductsData()); customers[customers.Count - 1].ProductID = Convert.ToInt32(sdr["ProductID"].ToString()); customers[customers.Count - 1].CategoryID = Convert.ToInt32(sdr["CategoryID"].ToString()); customers[customers.Count - 1].Title = sdr["Title"].ToString(); customers[customers.Count - 1].ThumbNail = sdr["ThumbNail"].ToString(); customers[customers.Count - 1].IsActive = Convert.ToBoolean(sdr["IsActive"].ToString()); customers[customers.Count - 1].FlashPath = sdr["FlashPath"].ToString(); customers[customers.Count - 1].Price = Convert.ToDouble(sdr["Price"]); customers[customers.Count - 1].Description = sdr["Description"].ToString(); //customers[customers.Count - 1].CustomerID = Convert.ToInt32(sdr["customer_id"]); //customers[customers.Count - 1].FirstName = sdr["firstname"].ToString(); //customers[customers.Count - 1].LastName = sdr["lastname"].ToString(); } con.Close(); //return customers; } } </code></pre> <p>Here when <code>Session["Products"]</code> value is <strong>1</strong> ,Data is coming and is entering in to while loop</p> <p>When <code>Session["Products"]</code> value is <strong>1,2</strong> ,while loop is not entering what is my problem with this code Plz can u suggest me </p> <p>Session data declaration Updated</p> <pre><code> protected void chkFocusArea_CheckedChanged(object sender, EventArgs e) { CheckBox cb = (CheckBox)sender; //update label count if checkbox is checked ListViewItem item = (ListViewItem)cb.NamingContainer; ListViewDataItem dataItem = (ListViewDataItem)item; string code = productslist.DataKeys[dataItem.DisplayIndex].Value.ToString(); //Header h1 = (Header)Page.LoadControl("~/UserControls/Header.ascx"); //CitandPrototype.UserControls.Header h1 = new UserControls.Header(); //Label mylabel = new Label(); //mylabel=(Label)h1.FindControl("lblitems"); string mylabel = ((Label)((this.Master).FindControl("Header")).FindControl("lblitems")).Text; string mylabelitems = ((HiddenField)((this.Master).FindControl("Header")).FindControl("lblitemshidden")).Value; if (!mylabelitems.Contains(code)) if (mylabel.Length == 0) { // mylabelitems += "," + code; mylabelitems = code; } else { // mylabelitems = code; mylabelitems += ","+code; } int.TryParse(mylabel, out x); if (cb.Checked) { x++; } else { if (x &gt; 0) x -= 1; else x = 0; mylabelitems=mylabelitems.Replace(code, string.Empty); } ((Label)((this.Master).FindControl("Header")).FindControl("lblitems")).Text =x.ToString(); ((HiddenField)((this.Master).FindControl("Header")).FindControl("lblitemshidden")).Value = mylabelitems.Trim(); Session["ProductCount"] = x.ToString(); Session["Products"] = mylabelitems.ToString(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload