无法转换值

Max*_*yne 0 c# asp.net

我试图转换Id字段将其发送到数据库但在DB中类型是bigInt:

var ID_Inscricao = (Label)row.FindControl("Label1");
Run Code Online (Sandbox Code Playgroud)

如何将其转换为与bigInt兼容的类型?我尝试过转换和转换,但都没有奏效.

Dav*_*New 7

您需要将标签的Text属性中的值转换为某种整数:

string labelText = ((Label)row.FindControl("Label1")).Text;
var ID_Inscricao = Convert.ToInt64(labelText);
Run Code Online (Sandbox Code Playgroud)

请注意,如果文本值不是数字,则可能会抛出异常.

  • 调试它并告诉我'labelText'是什么? (3认同)