Click here to Skip to main content
16,012,468 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
After assigning ddl selected value in session for just to make sure checked session value in immediate window in run mode
But it didn't take ddl vale
session["id"]
The name 'session' does not exist in the current context
C#
protected void btnsaveProduct_Click(object sender, EventArgs e)
    {

                  try
     {


con.Open();
       Label1.Text = DropDownList1.SelectedValue;
       Session["id"] = DropDownList1.SelectedValue;
        SqlCommand cmd = new SqlCommand("rsa_products_sp_ProductTable", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@Productname", txtProductName.Text);
        cmd.Parameters.AddWithValue("@ProductShortDescription", txtShortDescription.Text);
        cmd.Parameters.AddWithValue("@Productdescription", txtProductDescription.Text);
        cmd.Parameters.AddWithValue("@Price", txtPrice.Text);
        cmd.Parameters.AddWithValue("@MenuId", DropDownList1.SelectedItem.Value);>
     Please Help me with this.
Posted
Comments
ZurdoDev 9-Dec-14 14:33pm    
session should be capitalized Session. The error is actually saying it does not know what session is, not that it doesn't know what Session["id"] is.
kwelpooh 10-Dec-14 13:27pm    
yea that's silly mistake i have done Thanks
ZurdoDev 10-Dec-14 13:49pm    
You're welcome. Does that fix the whole question?

1 solution

Ryan is correct. The code seems good. But in immediate window, you are checking session["id"] instead of Session["id"].
 
Share this answer
 

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