Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将int值指定给隐藏字段_C#_Asp.net - Fatal编程技术网

C# 将int值指定给隐藏字段

C# 将int值指定给隐藏字段,c#,asp.net,C#,Asp.net,我需要给隐藏的文件赋值,但失败了 这是我的密码 ASP.NET <asp:HiddenField ID="hdnCId" runat="server" /> 隐藏字段只接受字符串 if (Request.QueryString["Id"] != "" && Request.QueryString["Id"] != null) { hdnCId.Value = Request.QueryString["Id"].ToString

我需要给隐藏的文件赋值,但失败了

这是我的密码

ASP.NET

<asp:HiddenField ID="hdnCId" runat="server" />

隐藏字段只接受字符串

if (Request.QueryString["Id"] != "" && Request.QueryString["Id"] != null)
        {
            hdnCId.Value = Request.QueryString["Id"].ToString();
        }
这就行了

使用时将值转换为int

//when there is some value in it

Int32 Id = Convert.ToInt32(hdnCId.Value);

隐藏字段只接受字符串

if (Request.QueryString["Id"] != "" && Request.QueryString["Id"] != null)
        {
            hdnCId.Value = Request.QueryString["Id"].ToString();
        }
这就行了

使用时将值转换为int

//when there is some value in it

Int32 Id = Convert.ToInt32(hdnCId.Value);

隐藏字段将值存储为字符串。 将代码更改为

 hdnCId.Value =Id.ToString();

隐藏字段将值存储为字符串。 将代码更改为

 hdnCId.Value =Id.ToString();