datagrid和repeader控件中替换标识值的方法
程序员文章站
2024-02-22 12:46:22
datagrid控件中替换标识值的使用:
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; }
上一篇: 小米推送Java代码