hello friends
I was trying cascading dropdown using jquery
I will list down my code
1. codebehind code:
[WebMethod]
public static List<DataRow> getVC(string strGEO)
{
try
{
List<DataRow> lstVC = new List<DataRow>();
SqlConnection objCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["SQL"].ConnectionString.ToString());
SqlCommand objCmd = new SqlCommand("FWB_GetVC", objCon);
objCon.Open();
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.AddWithValue("@EmployeeID", 8047);
objCmd.Parameters.AddWithValue("@GEOID", strGEO);
SqlDataAdapter objDA = new SqlDataAdapter();
objDA.SelectCommand = objCmd;
DataTable objDT = new DataTable();
objDA.Fill(objDT);
if (objDT.Rows.Count > 0)
{
lstVC = objDT.Select().ToList();
}
return lstVC;
}
catch (Exception e)
{ throw e; }
}
2. aspx code:
<script>
$(document).ready(function () {
});
function fillVC() {
try {
var value = $("#ddlGEO").val();
alert(value);
$.ajax({
type: "POST",
url: "CascadingDropDown_JQuery.aspx/getVC",
data: "{strGEO: '" + $('#ddlGEO').val() + "'}",
contentType: "application/json; char-set=utf-8",
dataType: "json",
success: function Success(data) {
loadVC(data.d);
}
});
}
catch (e) {
alert(e);
}
}
function loadVC(data){
alert("hi");
}
</script>
My problem is that, my code behind function is returning list object. It is not accessible in jquery, coz function loadVC is not getting called.
Any idea, what is going wrong??
And how can i access the list using jquery and bind it to dropdown??
Thanks in advance