Click here to Skip to main content
15,563,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am facing a problem with my cascading dropdownlist as the below dropdownlist depending on a cookie "Location" value. The error message is: "No mapping exists from object type System.Web.HttpCookie to a known managed provider native type."

if (!IsPostBack)
    HttpCookie cookie = Request.Cookies.Get("Location");
    if (cookie != null)

        DataTable StateDT = new DataTable();
        using (SqlConnection con2 = new SqlConnection(ConfigurationManager.ConnectionStrings["BeravaConnectionString"].ConnectionString))
            // Create the SelectCommand.
            SqlCommand command = new SqlCommand("SELECT State FROM State WHERE Country = @Location", con2);

            command.Parameters.AddWithValue("@Country", cookie);
            var Location = cookie.Value;

            SqlDataAdapter adaptar = new SqlDataAdapter();
            adaptar.SelectCommand = command;

            carstatedrdolst.DataSource = StateDT;
            carstatedrdolst.DataTextField = "State";


        carstatedrdolst.Items.Insert(0, new ListItem("Select State", ""));
Laiju k 12-Nov-14 23:19pm    
where did you get this error on your code
Member 10690878 13-Nov-14 5:11am    
Hi thanks for your kind reply, i get this error at this line: adaptar.Fill(StateDT);
Laiju k 13-Nov-14 23:20pm    
command.Parameters.AddWithValue("@Country", cookie);
I think the type of @Country should be that of the Database type not cookie

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