1.ENUM
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { GridViewRow row = e.Row; ) { return; } ].Text; int tempStatusNum = int.Parse(statusNum); ShipStatus temp2 = (ShipStatus)tempStatusNum; row.Cells[].Text = temp2.ToString(); } enum ShipStatus { 初始 = , 审核通过 = , 已发送 = }
2. AsEnumerable 思路,先把所有状态 放到一张临时表,再进行连接.
var dt = DataTableA var dtstatus = DtStatus(); var res = from a in dt.AsEnumerable() join s in DtStatus().AsEnumerable() on a["status"] equals s["statusEN"] into dtjoin from dj in dtjoin.DefaultIfEmpty() select new { orderCode = a["orderCode"], status = dj["statusCN"] //................... }; var dtres = Functions.EnumerableToDataTable(res); GVorderStatus.DataSource = dtres; public DataTable DtStatus() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("statusEN", typeof(System.String))); dt.Columns.Add(new DataColumn("statusCN", typeof(System.String))); dt.Rows.Add("WMS_ARRIVAL", "SS"); dt.Rows.Add("WMS_RECEIVED", "AA"); dt.Rows.Add("WMS_REJECT", "FF"); dt.Rows.Add("WMS_FAILED", "HH"); //....................... return dt; }