显示长日期格式和显示金额格式文本
2008-06-05 01:01
295 查看
数据库连接访问都是放在数据库访问类 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) 方法表示使用指定格式,将实例数值转化为它的等效字符串格式
明天再做详细解释
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) 方法表示使用指定格式,将实例数值转化为它的等效字符串格式
明天再做详细解释
相关文章推荐
- Dev gridView中设置自适应列宽和日期显示格式、金额的显示格式
- QT 文本html显示格式的问题,如在QTextBrowser.setText用tr(),其中为html格式
- 仅2行代码的javascript按指定格式显示日期时间效果
- c# 导出 身份证 到excel中 文本格式显示
- POI设置EXCEL单元格格式为文本、小数、百分比、货币、日期、科学计数法和中文大写
- C#练习——统计整型数组中不重复数字的个数、将普通日期格式转换成汉字日期格式、在控制台录入每个学生的姓名,当用户输入quit(不区分大小写)时,程序停止接受用户的输入,并且显示出用户输入的学生的个数
- GridView列数字、货币和日期的显示格式
- 日期显示格式
- mysql中调整时间日期显示格式
- DateTimePicker中自定义时间或日期显示格式
- 如何在GridView将数字显示成金额格式或自定义格式?
- 【JAVA】POI设置EXCEL单元格格式为文本、小数、百分比、货币、日期、科学计数法和中文大写
- gridview列 数字、货币和日期 显示格式
- oracle中修改日期的显示格式
- JS获取当前时间 格式 年月日 礼拜几 显示阴历日期 节气
- C# dateTimePicker 显示的格式日期
- gridview列 数字、货币和日期 显示格式
- Struts2 标签自定义格式显示数值、日期
- js按指定格式显示日期时间的样式代码
- GridView、Repeater等数据控件列数字、货币和日期的显示格式