c# - Error with binding my cascading dropdownlist -
i facing error message when move page in c# application page contain cascading dropdownlist. didnt know how can fix please me it.
the parameterized query '(@country nvarchar(4000))select state state country =' expects parameter '@country', not supplied.
protected void page_load(object sender, eventargs e) { httpcookie cookie = request.cookies.get("location"); if (!ispostback) { if (cookie != null) { datatable statedt = new datatable(); using (sqlconnection con2 = new sqlconnection(configurationmanager.connectionstrings["beravaconnectionstring"].connectionstring)) { // create selectcommand. sqlcommand command = new sqlcommand("select state state country = @country", con2); command.parameters.addwithvalue("@country", (cookie["location"])); sqldataadapter adaptar = new sqldataadapter(); adaptar.selectcommand = command; adaptar.fill(statedt); carstatedrdolst.datasource = statedt; carstatedrdolst.datatextfield = "state"; carstatedrdolst.databind(); } carstatedrdolst.items.insert(0, new listitem("select state", "")); } }
}
i think need values of cookie
httpcookie cookie = request.cookies["location"]; if(cookie != null) { object countryname= cookie.value; } else { //handle null }
Comments
Post a Comment