这一阶段写一个在线Web预订系统, 在完成预订单管理这块时候碰到一个设计思想是根据预订单流转的具体流程在gridview中改变相应颜色的内容,这时候正好碰到www.yesky.com上asp.net 2.0中Gridview控件高级技巧这篇文章中的一段例子
protected
void
GvSubscribe_RowDataBound(
object
sender, GridViewRowEventArgs e)
... {
if (e.Row.RowType == DataControlRowType.DataRow)
...{
int tempFlowId = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "FlowId"));
if (tempFlowId == 1)
e.Row.BackColor = Color.Blue;
if (tempFlowId == 2)
e.Row.BackColor = Color.Red;
if (tempFlowId == 3)
e.Row.BackColor = Color.Green;
if (tempFlowId == 4)
e.Row.BackColor = Color.Gray;
}
}
... {
if (e.Row.RowType == DataControlRowType.DataRow)
...{
int tempFlowId = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "FlowId"));
if (tempFlowId == 1)
e.Row.BackColor = Color.Blue;
if (tempFlowId == 2)
e.Row.BackColor = Color.Red;
if (tempFlowId == 3)
e.Row.BackColor = Color.Green;
if (tempFlowId == 4)
e.Row.BackColor = Color.Gray;
}
}
aspx页面文件为
<
table style
=
"
height: 16px; width: 564px;
"
cellpadding
=
0
cellspacing
>
< tr >< td >
未预订:草绿色 已预订:黄色 已烧录:兰色 已审批:红色 已回复:黑色 </ td ></ tr >
< tr >
< td style = " height: 250px;text-align: left; width:564px; " >< asp:GridView ID = " GvSubscribe " runat = " server " AllowPaging = " True " AllowSorting = " True "
AutoGenerateColumns = " False " DataSourceID = " SqlDataSource2 " Width = " 580px " Height = " 1px " OnRowDataBound = " GvSubscribe_RowDataBound " >
< Columns >
< asp:BoundField DataField = " PriId " HeaderText = " 优先级 " SortExpression = " PriId " />
< asp:BoundField DataField = " WorkId " HeaderText = " 施工人员工号 " SortExpression = " WorkId " />
< asp:BoundField DataField = " SubscriptionTitle " HeaderText = " 预订单标题 " SortExpression = " SubscriptionTitle " />
< asp:BoundField DataField = " SubscriptionOrderContent " HeaderText = " 预约订单内容 " SortExpression = " SubscriptionOrderContent " />
< asp:BoundField DataField = " WorkMaincontentId " HeaderText = " 施工工作事由Id号 " SortExpression = " WorkMaincontentId " />
< asp:BoundField DataField = " FlowId " HeaderText = " 流程号 " SortExpression = " FlowId " />
< asp:BoundField DataField = " AddDate " HeaderText = " 增加时间日期 " SortExpression = " AddDate " />
< asp:BoundField DataField = " DepartmentId " HeaderText = " 部门号 " SortExpression = " DepartmentId " />
< asp:CommandField ShowEditButton = " True " />
</ Columns >
</ asp:GridView >
< asp:SqlDataSource ID = " SqlDataSource2 " runat = " server " ConnectionString = " <%$ ConnectionStrings:OnlineSuscribeSystemConnectionString3 %> "
SelectCommand = " SELECT [SubscriptionTitle], [PriId], [WorkId], [SubscriptionOrderContent], [WorkMaincontentId], [FlowId], [AddDate], [DepartmentId] FROM [SubscriptionOrder] " DataSourceMode = " DataSet " >
</ asp:SqlDataSource >
& nbsp; & nbsp; </ td ></ tr >
</ table >
< tr >< td >
未预订:草绿色 已预订:黄色 已烧录:兰色 已审批:红色 已回复:黑色 </ td ></ tr >
< tr >
< td style = " height: 250px;text-align: left; width:564px; " >< asp:GridView ID = " GvSubscribe " runat = " server " AllowPaging = " True " AllowSorting = " True "
AutoGenerateColumns = " False " DataSourceID = " SqlDataSource2 " Width = " 580px " Height = " 1px " OnRowDataBound = " GvSubscribe_RowDataBound " >
< Columns >
< asp:BoundField DataField = " PriId " HeaderText = " 优先级 " SortExpression = " PriId " />
< asp:BoundField DataField = " WorkId " HeaderText = " 施工人员工号 " SortExpression = " WorkId " />
< asp:BoundField DataField = " SubscriptionTitle " HeaderText = " 预订单标题 " SortExpression = " SubscriptionTitle " />
< asp:BoundField DataField = " SubscriptionOrderContent " HeaderText = " 预约订单内容 " SortExpression = " SubscriptionOrderContent " />
< asp:BoundField DataField = " WorkMaincontentId " HeaderText = " 施工工作事由Id号 " SortExpression = " WorkMaincontentId " />
< asp:BoundField DataField = " FlowId " HeaderText = " 流程号 " SortExpression = " FlowId " />
< asp:BoundField DataField = " AddDate " HeaderText = " 增加时间日期 " SortExpression = " AddDate " />
< asp:BoundField DataField = " DepartmentId " HeaderText = " 部门号 " SortExpression = " DepartmentId " />
< asp:CommandField ShowEditButton = " True " />
</ Columns >
</ asp:GridView >
< asp:SqlDataSource ID = " SqlDataSource2 " runat = " server " ConnectionString = " <%$ ConnectionStrings:OnlineSuscribeSystemConnectionString3 %> "
SelectCommand = " SELECT [SubscriptionTitle], [PriId], [WorkId], [SubscriptionOrderContent], [WorkMaincontentId], [FlowId], [AddDate], [DepartmentId] FROM [SubscriptionOrder] " DataSourceMode = " DataSet " >
</ asp:SqlDataSource >
& nbsp; & nbsp; </ td ></ tr >
</ table >