如何从视图数据中获取特定的列值?

编程入门 行业动态 更新时间:2024-10-10 11:21:50
本文介绍了如何从视图数据中获取特定的列值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我从数据库中选择了一行. 数据看起来像这样

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的数据表或数据集.. 所以我尝试了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.. 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.

更多推荐

如何从视图数据中获取特定的列值?

本文发布于:2023-11-05 03:02:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559731.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!