原价<%#Eval("CostPrice")%>现价<%#Eval("Price") %>现在要绑定折扣和节省多少的字段啊,怎么算呢???折扣?????节省?????? 

解决方案 »

  1.   

    还有一个字段啊,数据库存储的开始时间和结束时间,格式是datetime类型的啊,开始时间是2010-07-14 11:27:02.000   结束时间是2010-07-14 11:27:02.000
    前台绑定的时候,要计算这个啊 剩余时间:<br />
                                    <span id="day">00</span> 天 <span id="hour">00</span> 小时 <span id="mini">00</span>
                                    分 <span id="sec">00</span> 秒</p>
    这个怎么操作啊·········
      

  2.   

    是mm吗,是MM可以以身相许~~哈哈。折扣
    <%#(Convert.ToInt32(Eval("Price"))/Convert.ToInt32(Eval("CostPrice"))).ToString()+"%" %>
    节省了<%#Convert.ToInt32(Eval("CostPrice"))-Convert.ToInt32(<%#Eval("Price")) %>元。
      

  3.   

     就这样啊,也可以在后台写方法 
    protact string getzhekou(object price, object costprice)
    {
         return Convert.ToDecimal(Eval("Price"))/Convert.ToDecimal(Eval("CostPrice")))+"节省了"+Convert.ToDecimal(Eval("CostPrice"))-Convert.ToDecimal(<%#Eval("Price")) ;
    }
      

  4.   

    节省了
    <%#Convert.ToInt32(Eval("CostPrice"))-Convert.ToInt32(<%#Eval("Price")) %>这一句报错了,是不是写错了啊····
      

  5.   


    <%#Convert.ToInt32(Eval("CostPrice"))-Convert.ToInt32(Eval("Price")) %>你中间多了个<%#
      

  6.   

    前台
    <span id="year" runat="server"></span>
    后台
    DateTime BeginTime,EndTime
    string year = EndTime.Subtract(BeginTime).Year.ToString()
    year.InnerText=year
    string day = EndTime.Subtract(BeginTime).Day.ToString()
    day.InnerText=day
    ....依次类推
      

  7.   

    对于绑定时需要显示格式比较复杂的或者需要计算的内容,可以自定义一个方法生成需要的内容,然后在绑定时调用。
    .aspx<%# GetDisplayContent(Container)%>.csprotected string GetDisplayContent(IDataItemContainer container)
    {
         YourType o = (YourType)container.DataItem
         return String.Format("{0:h'小时'm'分's'秒'}",o.StartTime-o.EndTime);
    }
      

  8.   

    我不太明白   YourType o = (YourType)container.DataItem
    这句什么意思
      

  9.   

    你的类型 o  = (你的类型)container.DateTtem  你现在是日期类型 所以就是datetime o = ()..强转 就是这个意思
      

  10.   

    在数据库中计算最好
    select Price/CostPrice  as 折扣,CostPrice  -Price as 节省 from tb
      

  11.   


    YourType就是你绑定的数据集的实体类型。
    如果你绑定的是DataTable,那么YourType就是DataRow,如果你绑定的是实体列表List<T>,那么YourType就是T。
      

  12.   

    脚本<script>
    function XX()
    {
     var o;   //折扣
     var p;    //节约
     o=<%#(Convert.ToInt32(Eval("Price"))/Convert.ToInt32(Eval("CostPrice"))).ToString()+"%" %>;
     p=<%#Convert.ToInt32(Eval("CostPrice"))-Convert.ToInt32(<%#Eval("Price")) %>;
    }
    </script>
    调用折扣<%=o%>
    节省<%=p%> 
      

  13.   

    protected string GetDisplayContent(IDataItemContainer container)
            {
                SC_GroupPurchase bll = new SC_GroupPurchase();
                DataTable list = bll.GetAllList().Tables[0];
                  
            }
    我这样把数据读到DataTable 了  接下来肿么办啊········
      

  14.   

     <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>在线日期计算器 时间,日期,天数计算器</title>
    <script>
    var hzWeek= new Array("日","一","二","三","四","五","六","日");function cweekday(wday){return hzWeek[wday];}
    function cala()
    {
    y=document.getElementById("SY").value;
    m=document.getElementById("SM").value;
    d=document.getElementById("SD").value;
    ddd=document.getElementById("decday").value;ttt=new Date(y,m-1,d).getTime()+ddd*24000*3600;theday=new Date();
    theday.setTime(ttt);
    document.getElementById("result1").innerHTML=theday.getFullYear()+"年"+(1+theday.getMonth())+"月"+theday.getDate()+"日"+"星期"+cweekday(theday.getDay());
    }
    function calb()
    {y2=document.getElementById("SY2").value;
    m2=document.getElementById("SM2").value;
    d2=document.getElementById("SD2").value;
    y3=document.getElementById("SY3").value;
    m3=document.getElementById("SM3").value;
    d3=document.getElementById("SD3").value;
    day2=new Date(y2,m2-1,d2);
    day3=new Date(y3,m3-1,d3);document.getElementById("result2").innerHTML=(day3-day2)/86400000;
    }
    </script>
    <style type="text/css">
    <!--
    body,td,th {
    font-size: 15px;
    }
    body {
    background-color: #99FFFF;
    }
    -->
    </style></head>
    <body>
    <a href=http://hi.csdn.net/space.php?do=home>yankai159357</a>
    <br>
    <br>
    <b>推算几天后的日期:</b>
    <br>
     和
    <input size=8 id=SY value=2008>年
    <input size=4 id=SM value=11>月
    <input size=4 id=SD value=27>日
    (缺省为今天)
    <br>相差
    <input size=8 id=decday value=100>天
    (输入负数则往前计算)
    <br>是:
    <span id=result1></span>
    <br>
    <input type=button value="计算" onclick="cala()">
    <br><br>
    <b>计算日期差:</b>
    <br>
      <input size=8 id=SY2 value=2009>年
    <input size=4 id=SM2 value=10>月
    <input size=4 id=SD2 value=30>日<br>
    和 <input size=8 id=SY3  value=2011 >年
    <input size=4 id=SM3 value=1>月
    <input size=4 id=SD3 value=1>日
    <br>相差:
    <span id=result2></span>天
    <br>
    <input type=button value="计算" onclick="calb()">
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <a href=http://www.beijing-time.org>返回首页</a>
    </bodY>
    </html>
      

  15.   

    protected string GetDisplayContent(IDataItemContainer container)
      {
      DataRow row = (DataRow)container.DataItem;
      return String.Format("{0:d'天'h'小时'm'分's'秒'}",(DateTime)row["StartTime"]-(DateTime)row["EndTime"];
      }
      

  16.   


    无法将类型为“System.Data.DataRowView”的对象强制转换为类型“System.Data.DataRow”。 
    ···········
    报错了
      

  17.   

    那就改成DataRowView
    protected string GetDisplayContent(IDataItemContainer container)
      {
      DataRowView row = (DataRowView)container.DataItem;
      return String.Format("{0:d'天'h'小时'm'分's'秒'}",(DateTime)row["StartTime"]-(DateTime)row["EndTime"];
      }
      

  18.   

    holy shit~
    折扣的
    <%#(Convert.ToInt32(Eval("Price"))/Convert.ToInt32(Eval("CostPrice"))).ToString()+"%" %>
    节省的
    <%#Convert.ToInt32(Eval("CostPrice"))-Convert.ToInt32(Eval("Price")) %>
    看你的精确度了。Convert.ToInt32-->这个类型你自己选择。