Click here to Skip to main content
15,914,642 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my shopping cart project I have a datalist displaying several products. Certain products are
available in certains seasons only. If an user clicks 'add to cart' button and if that product
does not belong to the current season then I want to show a label stating 'It is off season'
beneath that particular button alone inside the datalist. I tried with the
following code, no display of label is hapenning.

SqlCommand cmd4 = new SqlCommand("SELECT season from product WHERE CategoryId='" + v_categoryid + "' and ProductId='" + v_code + "' and season !='jan-dec'", con);
SqlParameter param4 = new SqlParameter();
param4.ParameterName = "@v_mem_id1";
param4.Value = "ss";
cmd4.Parameters.Add(param4);
con.Open();
SqlDataReader reader1 = cmd4.ExecuteReader();
if (reader1.HasRows)
{
while (reader1.Read())
{
string v_season = reader1.GetString(0);
Label11.Text = "check season";
Label11.Visible = true;


XML
<asp:TextBox ID="AddToCartTB"  runat = "server" Text='1' BackColor=GhostWhite style=" margin-left:11px" Width="34px"  > </asp:TextBox>
  <asp:Button ID="AddToCart"  runat = "server" Text='Add to Cart'  ForeColor="#333333"  BackColor="#ffcc66" Width="100px"  Style=" margin-top:-22px; margin-left:100px; font-family:Arial"  commandname="myevent">
  </asp:Button>
  <asp:Label ID="Label11" runat = "server"    Text="" style=" color: Silver">
   </asp:Label>
Posted
Comments
Sergey Alexandrovich Kryukov 5-Jun-14 2:47am    
What is that beast, "runtime label"? Do you know any non-runtime labels?
—SA
ZurdoDev 5-Jun-14 7:32am    
Just debug it and see what is happening.
S.Rajendran from Coimbatore 5-Jun-14 22:44pm    
in debug I could see label11 is assigned with 'Check season'
ZurdoDev 5-Jun-14 22:50pm    
Then what is the issue?
ZurdoDev 5-Jun-14 22:50pm    
Note: The color of the font of Lable11 is Silver. That may not show well on a screen depending on your background color. Also, I would suggest naming the control appropriately. It makes it easier to debug.

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