Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.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# 字典对象的类型错误_C#_Javascript_Jquery_Dictionary_Devexpress - Fatal编程技术网

C# 字典对象的类型错误

C# 字典对象的类型错误,c#,javascript,jquery,dictionary,devexpress,C#,Javascript,Jquery,Dictionary,Devexpress,更改数量值后,当我尝试单击表单上的按钮时,出现以下错误。密钥和数量得到了正确设置(正如我在调试期间看到的) 我不知道为什么会出错…… The value "1" is not of type "System.Int32" and cannot be used in this generic collection. Parameter name: value 我在网上查过这条消息,但我读到的任何东西都不能解释什么是错的 我将dictionary对象设置如下。请注意,我尝试将类型更改为string

更改数量值后,当我尝试单击表单上的按钮时,出现以下错误。密钥和数量得到了正确设置(正如我在调试期间看到的)

我不知道为什么会出错……

The value "1" is not of type "System.Int32" and cannot be used in this generic collection.
Parameter name: value
我在网上查过这条消息,但我读到的任何东西都不能解释什么是错的

我将dictionary对象设置如下。请注意,我尝试将类型更改为string,string并显示相同的消息(如上),但不是
“System.Int32”
“System.string”

在调试期间,在我更改数量后,dictionary对象包含正确的值

?dict[key]
1

?PageDataClient.Get("ClientSelectedQtyRows")
{...}
    [prototype]: {...}
    [41769]: 1
    [prototype]: [] 
“打印”按钮的标记如下所示:

<td style="padding-right: 10px;">
                                    <dx:ASPxButton ID="btnPrint" Text="Print" runat="server" ClientInstanceName="btnPrintClient" CausesValidation="false" ValidationGroup="CS" Theme="PlasticBlue" AutoPostBack="false" Enabled="false">
                                        <ClientSideEvents Click="function (s,e) { PerformCallback('1:'); btnPrintClient.disabled = true; btnSearchClient.disabled = true; }" />
                                    </dx:ASPxButton>
                                </td>

由于ASPXHiddenField不支持dictionary对象中的整数,因此我将其转换为一个

在JS函数中,我缺少一件事要做

我将值更改为:

dict[key]=parseInt(数量,10)

dict[key]=数量toString()


这就解决了问题…

您确定它没有添加
字符串
1
而不是整数1吗?正如您在我的调试值中看到的,键是41769,其值是1,而不是“1”。将其更改为
dict[key]=parseInt(数量,10)只是为了确保我按照您的建议修改了代码,并且在调试期间,得到了完全相同的值,消息仍然会出现。。。。我只是不明白这个让我头疼的简单错误:(
?dict[key]
1

?PageDataClient.Get("ClientSelectedQtyRows")
{...}
    [prototype]: {...}
    [41769]: 1
    [prototype]: [] 
<td style="padding-right: 10px;">
                                    <dx:ASPxButton ID="btnPrint" Text="Print" runat="server" ClientInstanceName="btnPrintClient" CausesValidation="false" ValidationGroup="CS" Theme="PlasticBlue" AutoPostBack="false" Enabled="false">
                                        <ClientSideEvents Click="function (s,e) { PerformCallback('1:'); btnPrintClient.disabled = true; btnSearchClient.disabled = true; }" />
                                    </dx:ASPxButton>
                                </td>