如何显示数据表中的标签文本?
我有一个通过代码创建的标签。我想通过一个返回数据表的函数来填充这个标签。此 DataTable 在返回中有 1 行和 1 列。
这是我的代码:
Label1.??? = Repository.Instance.ReturnScore(ddlPlayer1.ToString(), ddlPlayer2.ToString());
ReturnScore 给我的值是 DataTable。我应该如何获取其中的价值?
有什么帮助吗?
I am having a label which I am creating through code. I want to populate this label through a function which returns me a DataTable. This DataTable has 1 row and 1 column in the return.
This is my code:
Label1.??? = Repository.Instance.ReturnScore(ddlPlayer1.ToString(), ddlPlayer2.ToString());
ReturnScore is giving me the value as DataTable. How should I get the value in it?
Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个
这将返回第一行的第一个值。
Try this
This returns the first value of the first row.
DataTable 有一个 Rows 属性,Rows 返回的每个 Row 都有一个索引器,该索引器生成该行的列中包含的值。既然您已经说过只有一行和一列,您可以这样做:
或更简洁:
DataTable has a Rows property, and each Row returned by Rows has an indexer which yields the values contained in the columns for that row. Since you have said there will be just one row and one column, you can do this:
or more concisely:
我不记得确切的代码,但我认为它应该是这样的:
I don't remember the exact code but I think it should be something like: