I saw many forums where developers faced the similar issue but I could not find a proper solution for it,
So then I looked into the code of ComboBox.LoadPostData in AjaxControlToolkit.dll .
Inside LoadPostData we have Convert.Int32 which is throwing error when its not able to convert, To fix that I overrided LoadPostData method in my code and added below check.
protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
{
//Overriding AjaxControlToolkit method as Int32.Parse in base method was throwing exception.
logger.Debug("Inside overriden LoadPostData");
string[] values = postCollection.GetValues(this.HiddenFieldControl.UniqueID);
if (values == null)
{
return false;
}
int num;
if (int.TryParse(values[0], out num))
{
bool value = base.LoadPostData(postDataKey, postCollection);
return value;
}else
None
0 Points
1 Post
AjaxControlToolkit.ComboBox.LoadPostData "Input string was not in a correct format"
Mar 07, 2017 06:31 AM|SnehaAgrawal|LINK
When I submit a form which consists of AjaxToolKit ComboBox I was getting following error
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7469351
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
AjaxControlToolkit.ComboBox.LoadPostData(String postDataKey, NameValueCollection postCollection) +177
AjaxControlToolkit.ComboBox.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +36
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +693
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1743
I saw many forums where developers faced the similar issue but I could not find a proper solution for it,
So then I looked into the code of ComboBox.LoadPostData in AjaxControlToolkit.dll .
Inside LoadPostData we have Convert.Int32 which is throwing error when its not able to convert, To fix that I overrided LoadPostData method in my code and added below check.
protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
{
//Overriding AjaxControlToolkit method as Int32.Parse in base method was throwing exception.
logger.Debug("Inside overriden LoadPostData");
string[] values = postCollection.GetValues(this.HiddenFieldControl.UniqueID);
if (values == null)
{
return false;
}
int num;
if (int.TryParse(values[0], out num))
{
bool value = base.LoadPostData(postDataKey, postCollection);
return value;
}else
{
return false;
}
}
This works fine for me now.
If facing similar issue try the same :)