Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my code ..
when I run it comes error method 500..


using System;
using System.Collections;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections.Specialized;
using AjaxControlToolkit;
using System.Configuration;
using System.Data;

///
/// Summary description for DropdownWebService
///

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class DropdownWebService : System.Web.Services.WebService
{

[WebMethod]
public CascadingDropDownNameValue[] BindCountrydropdown(string knownCategoryValues, string category)
{
SqlConnection concountry = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
concountry.Open();
SqlCommand cmdcountry = new SqlCommand("select * from Country", concountry);
SqlDataAdapter dacountry = new SqlDataAdapter(cmdcountry);
cmdcountry.ExecuteNonQuery();
DataSet dscountry = new DataSet();
dacountry.Fill(dscountry);
concountry.Close();
List<cascadingdropdownnamevalue> countrydetails = new List<cascadingdropdownnamevalue>();
foreach(DataRow dtrow in dscountry.Tables[0].Rows)
{
string CountryID = dtrow["CountryId"].ToString();
string CountryName = dtrow["Country"].ToString();
countrydetails.Add(new CascadingDropDownNameValue(CountryName,CountryID));
}
return countrydetails.ToArray();
}
[WebMethod]
public CascadingDropDownNameValue[] BindStatedropdown(string knownCategoryValues, string category)
{
int CountryID;
StringDictionary countrydetails = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
CountryID = Convert.ToInt32(countrydetails["Country"]);
SqlConnection constate = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
constate.Open();
SqlCommand cmdstate = new SqlCommand("select * from countryState where CountryId=@CountryId", constate);
cmdstate.Parameters.AddWithValue("@CountryId", CountryID);
cmdstate.ExecuteNonQuery();
SqlDataAdapter dastate = new SqlDataAdapter(cmdstate);
DataSet dsstate = new DataSet();
dastate.Fill(dsstate);
constate.Close();
List<cascadingdropdownnamevalue> statedetails = new List<cascadingdropdownnamevalue>();
foreach (DataRow dtstaterow in dsstate.Tables[0].Rows)
{
string stateID = dtstaterow["StateId"].ToString();
string statename = dtstaterow["State"].ToString();
statedetails.Add(new CascadingDropDownNameValue(statename, stateID));
}
return statedetails.ToArray();
}
[WebMethod]
public CascadingDropDownNameValue[] BindRegiondropdown(string knownCategoryValues, string category)
{
int stateID;
StringDictionary statedetails = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
stateID = Convert.ToInt32(statedetails["State"]);
SqlConnection conregion = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
conregion.Open();
SqlCommand cmdregion = new SqlCommand("Select * from stateCity where StateId=@StateId", conregion);
cmdregion.Parameters.AddWithValue("@StateId", stateID);
cmdregion.ExecuteNonQuery();
SqlDataAdapter daregion = new SqlDataAdapter(cmdregion);
DataSet dsregion = new DataSet();
daregion.Fill(dsregion);
conregion.Close();
List<cascadingdropdownnamevalue> regiondetails = new List<cascadingdropdownnamevalue>();
foreach (DataRow dtregionrow in dsregion.Tables[0].Rows)
{
string regionID = dtregionrow["CityId"].ToString();
string regionname = dtregionrow["City"].ToString();
regiondetails.Add(new CascadingDropDownNameValue(regionname,regionID));

}
return regiondetails.ToArray();
}
}
Posted
Comments
Tejas Vaishnav 24-Sep-12 5:30am    
then what was the error and on which line you got that error.

do not put entire code like this instead please make some sense to put code with proper description for your error, and if possible line number also.

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