开发者

How to resolve error "Input String not in correct format"

Getting error on this line in my code:-

 objGetAdd.UserAddlID = int.Parse(e.CommandArgument.ToString());

Button in aspx page:-

<asp:Button ID="btnEditAdd" Text="Edit" 
CausesValidation="false" CommandName="Edit" Visible="false" runat="server" OnC开发者_如何学JAVAommand="btnEditAdd_Click" CommandArgument='<%#Eval("UserAddID") %>/>


You do not have a CommandArgument specified in Button "btnEditAdd".

However, you are then trying to int.Parse(e.CommandArgument.ToString())

Most likely the CommandArgument is null and hence the above line will fail.

Try adding a commandArgument="1" kind of value to your button first.


EDIT: Okay, so now you've changed the code... how about doing some debugging? What's the value of e.CommandArgument at execution time? What does the generated HTML look like? What is UserAddID when generating the page? These are questions which are hard for us to determine, but should be debugging 101 for you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜