本文介绍了如何使用viewdata检查完整列是否为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我有类似的东西



Hi I have something like

ViewData["getServices"] = (from p in dbObj.gen_crm_consolidate
                                       where p.service_id == sID && p.pdate >= sDate.Date && p.pdate <= eDate.Date
                                       orderby p.pdate descending
                                       select p).ToList();
return PartialView("_ServicePartial", ViewData["getServices"]);





并且在View中我使用此作为



and in View i am using this as

var q = (List<DM.Models.DB.gen_crm_consolidate>)(ViewData["getServices"]);
                           foreach (var item in q)
                           {





工作正常。我在ViewData中有近10-12列,只是我想查看天气完整列是否为空,如果它是空的,我将不会在视图中显示。



我尝试了什么:



我试图从viewdata访问q的值,但没有任何反应。



It is working perfectly fine. I have almost 10-12 columns in ViewData and just i want to check weather complete column is empty or not and if it is empty i will not show it in view.

What I have tried:

I tried to access value of q from viewdata but nothing happens.

推荐答案

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   
    <link href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet" />
    <script src="jquery.js"></script>
    <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
    

    <script>
        var table;




这篇关于如何使用viewdata检查完整列是否为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 16:29