DataGrid控件中替换标识值的使用:
01 <asp:DataGrid ID="dgList" runat="server" Width="100%" AutoGenerateColumns="False">
02 <Columns>
03 <asp:BoundColumn DataField="COP_G_NO" HeaderText="物料号/成品货号"></asp:BoundColumn>
04 <asp:BoundColumn DataField="QTY" HeaderText="数量"></asp:BoundColumn>
05 <asp:TemplateColumn HeaderText="物料标识">
06 <ItemTemplate>
07 <%#GetTransType(DataBinder.Eval(Container.DataItem, "FLAG"))%>
08 </ItemTemplate>
09 </asp:TemplateColumn>
10 </Columns>
11 </asp:DataGrid>
12 直接调用后台方法:
13 <asp:TemplateColumn HeaderText="原产地">
14 <ItemTemplate>
15 <%# (Common.Constant.CountryList.ContainsKey(Eval("COUNTRY") + "")) ? Common.Constant.CountryList[Eval("COUNTRY") + ""] : Eval("COUNTRY") + "" %>
16 </ItemTemplate>
17 </asp:TemplateColumn>
view sourceprint?01 public string GetTransType(object obj)
02 {
03 string type_flag = Convert.ToString(obj);
04 string strReturn = "";
05 switch (type_flag)
06 {
07 case "1": strReturn = "在厂产品"; break;
08 case "2": strReturn = "在厂半成品"; break;
09 case "3": strReturn = "已出库未报关成品"; break;
10 case "I": strReturn = "在厂原材料数量"; break;
11 case "Y": strReturn = "已报关未入库料件数量"; break;
12 case "W": strReturn = "已入库未报关料件数量"; break;
13 default: ; break;
14 }
15 return strReturn;
16 }
repeader控件中替换标识值的方法:
01 <asp:Repeater ID="rp_List" runat="server" OnItemCommand="rp_List_ItemCommand">
02 <ItemTemplate>
03 <tr>
04 <td>
05 <input id="chk" type="checkbox" name="chkName" runat="server" />
06 </td>
07 <td width="70">
08 <asp:HyperLink NavigateUrl='<%# getLink(Eval("CodeNameCn"),Eval("Guid"))%>' ID="hl_guid"
09 runat="server"><%# Eval("OrderNo")%></asp:HyperLink>
10 </td>
11 <td>
12 <%# Eval("CustomerNo")%><asp:HiddenField ID="hf_OrderNo" Value='<%# Eval("Guid") %>'
13 runat="server" />
14 </td>
15 <td>
16 <%# getInOrOut(Eval("IeType"))%>
17 </td>
18 <td>
19 <%# Eval("TradeMode")%>
20 </td>
21 <td>
22 <%# Eval("TotalQuantity")%>
23 </td>
24 <td>
25 <%# Eval("TotalAmount")%>
26 </td>
27 <td>
28 <%# Eval("ShipPeople")%>
29 </td>
30 <td>
31 <%# Eval("ReceivePeople")%>
32 </td>
33 <td>
34 <asp:LinkButton ID="lb_xiadan" runat="server" CommandName="xiadan"><%#getIsShowXiadan(Eval("Status"))%></asp:LinkButton>
35 </td>
36 <td>
37 <%# GetExistService(Eval("HasWMSService"), Eval("HasFreightAgent"), Eval("HasCustomsClearance"))%>
38 </td>
39 <td>
40 <%# Eval("CodeNameCn")%>
41 </td>
42 <td>
43 <%# Convert.ToDateTime(Eval("CreateTime")).ToString("yyyy-MM-dd")%>
44 </td>
45 </tr>
46 </ItemTemplate>
47 </asp:Repeater>
C#后台方法:
01 public string getLink(object objStatus, object objGuid)
02 {
03 if (objStatus == null)
04 {
05 return "#";
06 }
07 else if (objStatus + "" == "未下单")
08 {
09 return "GjmyOrderSave.aspx?guid=" + objGuid;
10 }
11 else
12 {
13 return "GjmyOrderDetail.aspx?guid=" + objGuid;
14 }
15 }
01 public string GetExistService(object objHasWMSService, object objHasFreightAgent, object objHasCustomsClearance)
02 {
03 string serviceHtml = "";
04 if (objHasWMSService != DBNull.Value)
05 {
06 if (Convert.ToBoolean(objHasWMSService) == true)
07 {
08 serviceHtml += " 仓库发货 ";
09 }
10 }
11
12 if (objHasFreightAgent != DBNull.Value)
13 {
14 if (Convert.ToBoolean(objHasFreightAgent) == true)
15 {
16 serviceHtml += " 货运代理 ";
17 }
18 }
19
20 if (objHasCustomsClearance != DBNull.Value)
21 {
22 if (Convert.ToBoolean(objHasCustomsClearance) == true)
23 {
24 serviceHtml += " 报关报检 ";
25 }
26 }
27 return serviceHtml;
28 }
中国足彩网信息请查看IT技术专栏
2025国考·省考课程试听报名