无法从'Object转换为Int' [英] Cannot convert from 'Object to Int'

查看:294
本文介绍了无法从'Object转换为Int'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用变量[id]帮助从我的ListView中选择某个项目,但是我一直收到标题中显示的错误。我怎么能解决这个问题,并允许[id]?

I am trying to use the variable [id] to help select a certain item from my ListView, but I keep getting this error as shown in the title. How can I get around this, and allow [id]?

这就是我的ListView背后的代码。

This is what my code behind looks like for my ListView.

推荐答案

如果id是可转换为int的DataType,则可以
unbox
它的值类型:

" DataRowView row = productsTable [(int)id];"

"DataRowView row = productsTable[(int)id];"

wizend


这篇关于无法从'Object转换为Int'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆