如何从视图数据中获取特定的列值? [英] how to get the specific column value from viewdata?

查看:76
本文介绍了如何从视图数据中获取特定的列值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从数据库中选择了一行.

数据看起来像这样

I selected a row from DB.

the data look like this

-------------------
productid |  Qty
-------------------
  123     |   12




我把它放在ViewData中.




I put this in ViewData.

ViewData["viewtest"] = selected data from above. (productid:123, qty:12)



在视图上,我只想从视图数据中获取qty 值.
我应该使用哪种语法?

我一直在考虑来自asp.net的数据表或数据集..
所以我尝试了ViewData["viewtest"][0]["qty"]...,等等都没用..

我必须同时使用两个值(productid和qty),并从视图中拆分该值..

有人可以帮忙吗?



on the View, I like to get only the qty value from the viewdata.
what kind of syntax should I use for that?

I keep thinking about datatable or dataset from asp.net..
So I tried ViewData["viewtest"][0]["qty"]... and so on which never works..

I have to bring the two values (productid and qty) at the same time and split the value from the view..

can anybody help???

thank you in advance.

推荐答案

为什么不尝试--

Why don''t you try as -

ViewData["ProductId"] = //select data for product id
ViewData["Quantity"] = //select data for quantity







HTH
拉杰夫

如果有帮助,请投票并标记答案为可接受.







HTH
Rajeev

Please vote and mark the answer as accepted if this helps you.


这篇关于如何从视图数据中获取特定的列值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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