All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.NET,2.0中判断上传的图片是否符合规格_[Asp.Net教程]
asp.net,2.0中使用OWC组件学习小结_[Asp.Net教程]
如何将Select查询结果保存到EXCEL中_[SQL Server教程]
ASP.NET程序与Access和SQL,Server数据库连接_[Asp.Net教程]
上传图片生成略缩图“最佳解决”_[Asp.Net教程]
ASP.NET,MasterPage,中图片路径的解决办法_[Asp.Net教程]
select控件在Mozilla和Opera中的问题_JavaScript技术_编程技术
ASP.NET&Spring.NET&NHibernate最佳实践(三)——第2章环境准备_[Asp.Net教程]
C#中定义鼠标指针形状的方法实例
C#中的异常处理语句
Reading number is top 10 pictures
再来随便发几张
More attractive than sora aoi3
Absolutely shocked. National geographic 50 animal photographys6
29 the belle stars after bath figure2
Sora aoi on twitter2
毛俊杰-能量永动机
So beauty, will let you spray blood3
Ashlynn Brooke a group sexy photo4
China telecom 114 spokesman MeiYanXu2
XuRe xuan cool and refreshing photoes2
Download software ranking
SP3 for SQL2000
株洲本地在线棋牌游戏
Unix video tutorial15
Tram sex maniac 2 (H) rar bag19
电脑知识及技巧大合集
The king of fighters 97(Mobile phone games-apk)
Tram sex maniac 2 (H) rar bag3
asp.net技术内幕
dreamweaver8中文版
Boxer vs Yellow1
归海一刀 published in(发表于) 2014/1/30 1:36:24 Edit(编辑)
按实际要求格式化显示DataGrid中字段值的方法_[Asp.Net教程]

按实际要求格式化显示DataGrid中字段值的方法_[Asp.Net教程]

按实际要求格式化显示DataGrid中字段值的方法_[Asp.Net教程]
源程序:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HTMLControls;

///
/// Summary description for idbSample.
///

public class idbSample : System.Web.UI.Page
{

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.dgContacts.ItemDataBound +=
new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgContacts_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

protected System.Web.UI.WebControls.DataGrid FormatDataGrid;

private DataSet _dsContacts;

private void Page_Load(object sender, System.EventArgs e)
{
// 装载XML数据原,注意:这里与数据原类型没有关系,换成数据库也是适用的
_dsContacts = new DataSet();
_dsContacts.ReadXML(Server.MapPath("Contacts.XML"));
DataColumn[] dcPk = {_dsContacts.Tables["Contact"].Columns["Email"]};
_dsContacts.Tables["Contact"].PrimaryKey = dcPk;

if (!Page.IsPostBack )
{
BindContacts();
}
}

private void BindContacts()
{
DataView dv = new DataView(_dsContacts.Tables["Contact"]);
dv.Sort = "LastName, FirstName";
dgContacts.DataSource = dv;
dgContacts.DataBind();
}

protected string FormatFullName(object FirstName, object LastName)
{
// 格式划名称列
return (string)LastName + ", " + (string)FirstName;
}

protected void FormatDataGrid_ItemDataBound(object source,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
// 确保处理的是数据行,而不是Header或者Footer
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
// 得到Manager字段的值
string isManager = (string)DataBinder.Eval(e.Item.DataItem, "Manager");

if (isManager == "1")
{
// ’ 设定文字和背景颜色
e.Item.Cells[2].Text = "经理"
e.Item.Cells[2].Style.Add("font-weight", "bold")
e.Item.Cells[2].ForeColor = System.Drawing.Color.Red
e.Item.BackColor = System.Drawing.Color.AliceBlue
}
else
{
e.Item.Cells[2].Text = "普通员工";
}
}
}
}




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.