AJAX Problem

B

bbawa1

I am trying to use cascadingdropdown AJAX control but it gives me
following error. have the following web method

public FoodService()
{

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public CascadingDropDownNameValue[] GetItemsByCategoryID(string
KnownCategoryValues, string category)
{
string[] _categoryValues = KnownCategoryValues.Split(':',
';');
int _foodID = Convert.ToInt32(_categoryValues[1]);
List<CascadingDropDownNameValue> _foodItems = new
List<CascadingDropDownNameValue>();
dsFoodTableAdapters.tbparentTableAdapter _foodAdapter =
new dsFoodTableAdapters.tbparentTableAdapter();


foreach (DataRow _row in _foodAdapter.GetFoodData())
{
_foodItems.Add(new
CascadingDropDownNameValue(_row["category"].ToString(),
_row["categoryID"].ToString()));

}

// convert to array and return the vlaues
return _foodItems.ToArray();
}




Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace
below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an
object.]

AjaxControlToolkit.CascadingDropDown.CascadingDropDown_ClientStateValuesLoaded(Object
sender, EventArgs e) +96
AjaxControlToolkit.ExtenderControlBase.LoadClientStateValues() +204
AjaxControlToolkit.ExtenderControlBase.Page_PreLoad(Object sender,
EventArgs e) +28
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Page.OnPreLoad(EventArgs e) +96
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+2794
 
C

Cowboy \(Gregory A. Beamer\)

1. Make sure you are always sending in a value for KnownCategoryValues and
not a null string.
2. Ensure there are at least two categoryValues, as _categoryValues[1] is
the second item; _categoryValues[0] would be the first item.
3. Check the data and make sure there are no rows with an empty Category or
CategoryID.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top