c# - int index = Convert.ToInt32(e.CommandArgument.ToString());不管用

标签 c# asp.net

请帮帮我。

int index = Convert.ToInt32(e.CommandArgument.ToString());

这对我不起作用。它显示异常,因为“输入字符串的格式不正确。”。

e.CommandArgument 不为空,我正在获取它的值(value)。

最佳答案

您应该像下面这样更改您的代码

int index;
bool bIsConverted = int.TryParse(e.CommandArgument.ToString(), out index);

关于c# - int index = Convert.ToInt32(e.CommandArgument.ToString());不管用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20345332/

相关文章:

c# - 向 SKBitmap 图像添加透明度会导致黑色背景

c# - 在 Windows CE 6.0 中访问 MySQL 服务器

c# - C# 中的 Array.Sort 为何如此超快?

c# - Visual Studio 在设计器模式下打开我的类文件 (.cs)

html - 为什么在 ASP.NET 中包含 runat ="server"

c# - 加载图像显示 ASP.NET 中的所有服务器端请求以及客户端请求

c# - 系统.Data.SqlClient.SqlConnection “Exception: Unknown packet type 74”

c# - 如何区分作为 DIV 的 HtmlGenericControl 和作为 UL 的 HtmlGenericControl?

javascript - 提交按钮上弹出 Html 确认弹出窗口

asp.net - HttpApplicationState.RemoveAll() 线程安全吗?