首页 新闻 赞助 找找看

对绑定表达式返回的值判断后显示.

0
悬赏园豆:20 [已解决问题] 解决于 2011-12-28 18:59

请教一下.

我通过绑定表达式获取一个字段的值. 该字段是int类型. 分别会有 0. 1 . 2 . 3 .4

5种状态. 

如何通过判断返回的值显示相应的文字呢 ?

jayccc的主页 jayccc | 初学一级 | 园豆:128
提问于:2011-12-27 15:17
< >
分享
最佳答案
0

是gridview吗?

if (e.Row.RowType == DataControlRowType.DataRow)
        {
            View_OPR_Inventory v = (View_OPR_Inventory)e.Row.DataItem;

            if (v.F_PurchasePrice == 0m)
            {
                e.Row.Cells[2].Text = string.Empty;
            }
            if (v.F_Price == 0m)
            {
                e.Row.Cells[3].Text = string.Empty;
            }
            if (v.F_Count == 0m)
            {
                e.Row.Cells[7].Text = string.Empty;
            }

string strTotal = e.Row.Cells[7].Text.ToString().Trim() == "" ? "0" : e.Row.Cells[7].Text.ToString().Trim();
            sum += decimal.Parse(strTotal);
        }

        if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Left;
            e.Row.Cells[0].Text = "合计";
            e.Row.Cells[7].HorizontalAlign = HorizontalAlign.Right;
            e.Row.Cells[7].Text = sum.ToString("F2");
        }

可以参照这个。

收获园豆:20
悟行 | 专家六级 |园豆:12559 | 2011-12-27 15:26

不是呢, repeater. 我想在aspx上实现, <% %> 里面要怎么写呢

jayccc | 园豆:128 (初学一级) | 2011-12-27 15:27

@jayccc: <%# Eval("F_GUID") %>

悟行 | 园豆:12559 (专家六级) | 2011-12-27 15:28

@jayccc: <%# int.parse(Eval("ID"))==1?"男":"女" %>

悟行 | 园豆:12559 (专家六级) | 2011-12-27 15:30

@痛苦造就性格:   有5种情况呢. 不是两种

jayccc | 园豆:128 (初学一级) | 2011-12-27 15:36

@jayccc: 那就在RowDataBound是事件中判断,像上面过滤掉数字一样判断。

悟行 | 园豆:12559 (专家六级) | 2011-12-27 15:37

@痛苦造就性格:  可以通过 switch(返回值) { case 1:  case 2  }  这样吗

jayccc | 园豆:128 (初学一级) | 2011-12-27 16:13

@jayccc:   可以的。

悟行 | 园豆:12559 (专家六级) | 2011-12-28 09:23
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册