后台动态绑定数据

直接上代码

aspx页面

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Couponlist.aspx.cs" Inherits="Coupon_Couponlist" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title>优惠券页面</title>
    <link href="../css/layout.css" rel="stylesheet" type="text/css" />
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
</head>
<body>
<div class="container">
<ul class="coupon_list">
        <%=str %>
      </ul>

</div>

</body>
</html>

aspx.cs后台

  public string str="";
    protected void Page_Load(object sender, EventArgs e)
    {
       string bbid=Request.QueryString["bbid"];
       string ppid = Request.QueryString["ppid"];
       if (!string.IsNullOrEmpty(bbid) && !string.IsNullOrEmpty(ppid))
       {
           getCouponList(bbid, ppid);//获取优惠券列表
       }
       else {
           ClientScript.RegisterStartupScript(this.GetType(), "message", "<script language=‘javascript‘>alert(‘参数不全!‘,‘提示‘);</script>");
       }

    }

    private void getCouponList(string bbid,string ppid)
    {
        string sql = string.Format("select * from v_couponlist where bbid={0} and ppid={1}",bbid,ppid);

        DataTable dt = SqlHelper.ExecuteTable(sql);
        if (dt!=null&&dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string thisdate = "";
                if (Convert.ToInt32(dt.Rows[i]["LastDay"]) > 0)
                {
                    thisdate = "发券后" + Convert.ToInt32(dt.Rows[i]["LastDay"]) + "天有效";
                }
                else
                {
                    thisdate = "有效期" + php.GetFormatDatedian(dt.Rows[i]["StartDate"].ToString()) + "-" + php.GetFormatDatedian(dt.Rows[i]["EndDate"].ToString());
                }
                 if (Convert.ToInt32(dt.Rows[i]["CouponType"]) == 1)
                 {

                     str += "<li>"+
            "<a href=‘CouponInfo.aspx?id="+dt.Rows[i]["id"]+"&bbid="+bbid+"&ppid="+ppid+"‘ class=‘relative clearfix‘>"+
                "<div class=‘quan_info fl‘>"+
                    "<h3>满减券</h3>"+
                    "<p>消费金额满 " + Convert.ToDecimal(dt.Rows[i]["PayMoney"]).ToString("f2") + "元可用</p>" +//Convert.ToDecimal(Eval("sale")).ToString("f2")
                    "<p>" + thisdate + "</p>" +
                "</div>"+
                "<div class=‘right_icon fr‘><div class=‘circle‘><span>¥</span>" + Convert.ToDecimal(dt.Rows[i]["CouponMoney"]).ToString("f2") + "</div></div>" +
            "</a>"+
        "</li>";
                 }
                 else {
                     str += "<li class=‘gift_card‘>"+
            "<a href=‘coupon-ny.html‘ class=‘relative clearfix‘>"+
                "<div class=‘quan_info fl‘>"+
                    "<h3>礼品券</h3>"+
                    "<p>到店消费领取<b>[" + dt.Rows[i]["Gift"] + "]</b></p>" +
                    "<p>"+thisdate+"</p>"+
                "</div>"+
                "<div class=‘right_icon fr‘><div class=‘circle‘></div></div>"+
            "</a>"+
        "</li>";

                 }
            }

        }
    }

静态页效果

<html>
 <head></head>
 <body>
  <div>
   <table class="allstyle" cellspacing="0" rules="all" border="1" id="InfoList" style="width:100%;border-collapse:collapse;">
    <tbody>
     <tr class="baojia_tit" style="border-style:None;height:50px;">
      <th scope="col">ID</th>
      <th scope="col">名称</th>
      <th scope="col">优惠详情</th>
      <th scope="col">每人限领</th>
      <th scope="col">库存</th>
      <th scope="col">创建时间</th>
      <th align="center" scope="col" style="font-weight:normal;">操作</th>
     </tr>
     <tr class="row" align="center" style="background-color:#F9F9F9;height:50px;">
      <td class="bottomLine"> 19 </td>
      <td class="bottomLine"> 满减券 </td>
      <td class="bottomLine" style="width:350px;"> aaaaaaaaaaaaaaaaaa </td>
      <td class="bottomLine"> 2 </td>
      <td class="bottomLine"> 100 </td>
      <td class="bottomLine"> 2016/11/18 21:11:57 </td>
      <td class="bottomLine1"> <a href="UpCoupon.aspx?id=19">修改</a> <a href="javascript:void(0)" onclick="Del(19)">删除</a> </td>
     </tr>
     <tr class="row" align="center" style="background-color:#EAEAEA;height:50px;">
      <td class="bottomLine"> 10 </td>
      <td class="bottomLine"> 礼品券 </td>
      <td class="bottomLine" style="width:350px;"> 仅限周一到周五使用 </td>
      <td class="bottomLine"> 2 </td>
      <td class="bottomLine"> 100 </td>
      <td class="bottomLine"> 2016/11/18 14:41:43 </td>
      <td class="bottomLine1"> <a href="UpCoupon.aspx?id=10">修改</a> <a href="javascript:void(0)" onclick="Del(10)">删除</a> </td>
     </tr>
    </tbody>
   </table>
  </div>
 </body>
</html>

时间: 2024-08-10 06:37:50

后台动态绑定数据的相关文章

bootstrap selectpicker 通过代码指定选中值 BootStrap selectpicker后台动态绑定数据 selectpicker 获取选中option的属性或者值

bootstrap-select使用 bootstrap selectpicker 通过代码指定选中值 $('#subjectno').selectpicker('val',(row.subjectno)); row.subjectno替换成你要指定的值,当然前提必须要在select已有的数据中 selectpicker 获取选中option的属性或者值 BootStrap selectpicker后台动态绑定数据

BootStrap selectpicker后台动态绑定数据

项目使用BootStrap设置select时,不能动态加载,使用以下方法可以解决. //获得全部订单信息(订单ID,订单名称) function GetAllOrders(obj) { $.ajax({ type: 'Get', url: '/OrderTypeSetting/GetAllCanUseOrderTypes/', dataType: "Json", success: function (data) { if (!data.flag) { $.each(data, func

HighChat动态绑定数据 数据后台绑定(四)

后台绑定数据,直接返回json数据 IList<SummaryHour> adHourData = summarybll.FindList(str); List<int> Hour = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }; List<int> downNumber = new List&

HighChat 动态绑定数据记录

最近刚开始做图形操作,纠结了一上午,highchat 动态绑定数据这块一直不知道怎么绑定,后来多次尝试,发现 1.x轴的数据是个数组格式,我从后台传到前台的时候,js中用数组进行处理数据,然后赋值到chat就不会报错, 2.y轴的数据和x轴数据还不一样,通过数组处理后发现还是无法显示.后来我在后台将数据添加了中括号[]括起来后,传到前台,然后前台在用eval()处理后就能够显示了 3.eval具有计算的功能,刚开始x轴的时候我用了eval对时间进行操作发现时间都是相减了,格式为:2017-07-

bootstrap select下拉框模糊搜索和动态绑定数据解决方法

此方法适合后台一次性返回所有数据好了废话不多说直接上代码: <!DOCTYPE html><html><head> <title>Bootstrap-select test page</title> <meta charset="utf-8"> //代码自己下载 <link rel="stylesheet" href="http://www.jq22.com/jquery/boo

代码: 两列图片瀑布流(一次后台取数据,图片懒加载。下拉后分批显示图片。图片高度未知,当图片onload后才显示容器)

代码: 两列图片瀑布流(一次后台取数据,无ajax,图片懒加载.下拉后分批显示图片.图片高度未知,当图片onload后才显示容器) [思路]: 图片瀑布流,网上代码有多种实现方式,也有各类插件.没找到合意的,所以根据网上找的一段代码,进行了较大改动. 需引用 zepto 或 jquery. 我这个是应用于手机上的,两列瀑布流,图片高度未知——等图片的onloaded事件触发后,才对容器进行计算和定位. 大容器是 $("#imgList"),容器格子是$(".pin"

ajax从asp后台获取数据

1.前台 $.ajax({ //url: "demo/data/taskTree.txt", url: "GanttChart.aspx?taskList=1" , cache: false, success: function (text) { var data = mini.decode(text); gantt.loadTasks(data); gantt.unmask(); //折叠全部 //gantt.collapseAll(); } }); 2.后台 ?

通过AngularJS实现前端与后台的数据对接(一)

最近,笔者在做一个项目:使用AngularJS,从而实现前端与后台的数据对接.笔者这是第一次做前端与后台的数据对接的工作,因此遇到了许多问题.笔者在这些问题中,总结了一些如何实现前端与后台的数据对接的方法,希望与大家分享. 在开始进行前端与后台的数据对接前,首先要做到以下几点: 1.先要了解页面哪里是需要后台提供数据的(即:哪里是需要接接口的) ps:很明显,表格里的数据就是要向后台发送请求,从数据库里获取页面需要显示的数据 2.要理解接口里的每一个字段的含义 ps:一般而言,前端工作者都可以根

SAP R3 用系统自带的功能查看后台数据库数据 SE16

SAP R3 用系统自带的功能查看后台数据库数据 如果用户端没有装oracle专用的查看表内容的工具软件 ,就可以用SAP 自带的功能查看,也可以实现,现介绍一下方法: 直接输入T-code: SE16 上下图对比,显示的所有的字段都是一致的. 建议用系统自带的SE16查看,不得已才用第三方工具.