开发者

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

开发者 https://www.devze.com 2023-01-26 19:59 出处:网络
Getting error on this line in my code:- objGetAdd.UserAddlID = int.Parse(e.CommandArgument.ToString());

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

精彩评论

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

关注公众号