zoukankan      html  css  js  c++  java
  • 显示长日期格式和显示金额格式文本

    数据库连接访问都是放在数据库访问类 SqlHelper.cs类里面 这里是保证程序的完成性 所以每个操作都加上了繁琐的操作 呵呵~~~~
           SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=123456;database=Member");
            string sql = "select * from tbMember";
            //SqlCommand cmd = new SqlCommand(sql, con);
            SqlDataAdapter sda = new SqlDataAdapter(sql, con);
            DataSet ds = new DataSet();
            sda.Fill(ds, "tbMember"); //重新命名下
            this.DataList1.DataSource = ds;
            this.DataBind(); //绑定数据
            DataRowView drv = ds.Tables["tbMember"].DefaultView[0];
            for (int i = 0; i <= this.DataList1.Items.Count - 1; i++)
            {
                Label lab = (Label)this.DataList1.Items[i].FindControl("Label1");
                DateTime dt = Convert.ToDateTime(drv["date"]);
                lab.Text = dt.ToLongDateString();
            }
            //本例子主要使用DateTime对象的ToLongDateString()方法将数据库中的数据转化成长日期格式 2006年5月5日

            SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=123456;database=Member");
            string sql = "select * from tbMember";
            //SqlCommand cmd = new SqlCommand(sql, con);
            SqlDataAdapter sda = new SqlDataAdapter(sql, con);
            DataSet ds = new DataSet();
            sda.Fill(ds, "tbMember"); //重新命名下
            this.DataList1.DataSource = ds;
            this.DataBind(); //绑定数据
            DataRowView drv = ds.Tables["tbMember"].DefaultView[0];
            for (int i = 0; i <= this.DataList1.Items.Count - 1; i++)
            {
                Label lab = (Label)this.DataList1.Items[i].FindControl("Label2");
                int money = Convert.ToInt32(drv["money"]);
                lab.Text = money.ToString();
            }
            //int.Tostring(string format) 方法表示使用指定格式,将实例数值转化为它的等效字符串格式

    明天再做详细解释

  • 相关阅读:
    Treap 树堆 容易实现的平衡树
    (转)Maven实战(二)构建简单Maven项目
    (转)Maven实战(一)安装与配置
    根据请求头跳转判断Android&iOS
    (转)苹果消息推送服务器 php 证书生成
    (转)How to renew your Apple Push Notification Push SSL Certificate
    (转)How to build an Apple Push Notification provider server (tutorial)
    (转)pem, cer, p12 and the pains of iOS Push Notifications encryption
    (转)Apple Push Notification Services in iOS 6 Tutorial: Part 2/2
    (转)Apple Push Notification Services in iOS 6 Tutorial: Part 1/2
  • 原文地址:https://www.cnblogs.com/ivy/p/1214008.html
Copyright © 2011-2022 走看看