datagrid和repeader控件中替换标识值的方法

DataGrid控件中替换标识值的使用:

<ASP:DataGrid ID="dgList" runat="server" Width="100%" AutoGenerateColumns="False"> <Columns> <ASP:BoundColumn DataField="COP_G_NO" HeaderText="物料号/成品货号"></ASP:BoundColumn> <ASP:BoundColumn DataField="QTY" HeaderText="数量"></ASP:BoundColumn> <ASP:TemplateColumn HeaderText="物料标识"> <ItemTemplate> <%#GetTransType(DataBinder.Eval(Container.DataItem, "FLAG"))%> </ItemTemplate> </ASP:TemplateColumn> </Columns> </ASP:DataGrid>直接调用后台方法:<ASP:TemplateColumn HeaderText="原产地"> <ItemTemplate> <%# (Common.Constant.CountryList.ContainsKey(Eval("COUNTRY") + "")) ? Common.Constant.CountryList[Eval("COUNTRY") + ""] : Eval("COUNTRY") + "" %> </ItemTemplate> </ASP:TemplateColumn>
public string GetTransType(object obj) { string type_flag = Convert.ToString(obj); string strReturn = ""; switch (type_flag) { case "1": strReturn = "在厂产品"; break; case "2": strReturn = "在厂半成品"; break; case "3": strReturn = "已出库未报关成品"; break; case "I": strReturn = "在厂原材料数量"; break; case "Y": strReturn = "已报关未入库料件数量"; break; case "W": strReturn = "已入库未报关料件数量"; break; default: ; break; } return strReturn; }

repeader控件中替换标识值的方法:

<ASP:Repeater ID="rp_List" runat="server" OnItemCommand="rp_List_ItemCommand"> <ItemTemplate> <tr> <td> <input id="chk" type="checkbox" name="chkName" runat="server" /> </td> <td width="70"> <ASP:HyperLink NavigateUrl='<%# getLink(Eval("CodeNameCn"),Eval("Guid"))%>' ID="hl_guid" runat="server"><%# Eval("OrderNo")%></ASP:HyperLink> </td> <td> <%# Eval("CustomerNo")%><ASP:HiddenField ID="hf_OrderNo" Value='<%# Eval("Guid") %>' runat="server" /> </td> <td> <%# getInOrOut(Eval("IeType"))%> </td> <td> <%# Eval("TradeMode")%> </td> <td> <%# Eval("TotalQuantity")%> </td> <td> <%# Eval("TotalAmount")%> </td> <td> <%# Eval("ShipPeople")%> </td> <td> <%# Eval("ReceivePeople")%> </td> <td> <ASP:LinkButton ID="lb_xiadan" runat="server" CommandName="xiadan"><%#getIsShowXiadan(Eval("Status"))%></ASP:LinkButton> </td> <td> <%# GetExistService(Eval("HasWMSService"), Eval("HasFreightAgent"), Eval("HasCustomsClearance"))%> </td> <td> <%# Eval("CodeNameCn")%> </td> <td> <%# Convert.ToDateTime(Eval("CreateTime")).ToString("yyyy-MM-dd")%> </td> </tr> </ItemTemplate> </ASP:Repeater>

C#后台方法:

public string getLink(object objStatus, object objGuid) { if (objStatus == null) { return "#"; } else if (objStatus + "" == "未下单") { return "GjmyOrderSave.ASPx?guid=" + objGuid; } else { return "GjmyOrderDetail.ASPx?guid=" + objGuid; } }
public string GetExistService(object objHasWMSService, object objHasFreightAgent, object objHasCustomsClearance) { string serviceHtml = ""; if (objHasWMSService != DBNull.Value) { if (Convert.ToBoolean(objHasWMSService) == true) { serviceHtml += " 仓库发货 "; } } if (objHasFreightAgent != DBNull.Value) { if (Convert.ToBoolean(objHasFreightAgent) == true) { serviceHtml += " 货运代理 "; } } if (objHasCustomsClearance != DBNull.Value) { if (Convert.ToBoolean(objHasCustomsClearance) == true) { serviceHtml += " 报关报检 "; } } return serviceHtml; }

AspNet技术datagrid和repeader控件中替换标识值的方法,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。