开发者

Input string was not in a correct format [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_如何转开发 Closed 11 years ago.

I am getting the following error on below code.

Input string was not in a correct format.

Code:

private void RefreshListType(bool forExport)
{
    grdListItems.DataSource = ListType.GetListTypes(Convert.ToInt16(cboListType.SelectedValue));
    grdListItems.DataBind();
    lblCount.InnerText = "LookUps: " + grdListItems.Rows.Count.ToString();
}

Please help me.


Likely cboListType.SelectedValue is not able to be made into an int16.

You can use int16.TryParse.


SelectedValue doesn't return a number?

You could put a TryParse in before to check that the selected item has a numeric value.

Int16 nValue = -1;
if (Int16.TryParse(cboListType.SelectedValue, out nValue))
{
    // Proceed
}


The value you are getting from cboListType.SelectedValue is not convertible to Int16.

Right-click on the page and select "View Source" and then hit Control-F to search for "cboListType" look at the value that is selected.

You can also use Response.Write or a javascript alert to write the value.


This, most likely, means that cboListType.SelectedValue is not a valid number

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜