cs代码:
//从表
IEnumerable<BCostProjectAppConfigDetail> dtconfig =
lists.Where(c => c.TableName == BCostProjectInventoryApplyDetail.Schema.TableName);
string script = String.Format("var colmodel = X('{0}').getColumnModel();",gridDetail.ClientID);;
string headerScript ="colmodel.setColumnHeader(colmodel.getIndexById('{0}'), '{1}');";
foreach (var detail in dtconfig)
{
#region 控制列显示
switch (detail.FieldName.ToLower())
{
case "cpid":
colCPName.Hidden = false;
colCPName.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colCPName.ClientID, detail.ChinaName);
break;
case "inventoryid":
colInvCCode.Hidden = false;
colInvCCode.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colInvCCode.ClientID, detail.ChinaName);
break;
case "inventorycode":
colInventoryCode.Hidden = false;
colInventoryCode.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colInventoryCode.ClientID, detail.ChinaName);
break;
case "inventoryname":
colInventoryName.Hidden = false;
colInventoryName.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colInventoryName.ClientID, detail.ChinaName);
break;
case "comunitname":
colComUnitName.Hidden = false;
colComUnitName.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colComUnitName.ClientID, detail.ChinaName);
break;
case "invstd":
colInvStd.Hidden = false;
colInvStd.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colInvStd.ClientID, detail.ChinaName);
break;
case "invsprice":
colInvSPrice.Hidden = false;
colInvSPrice.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colInvSPrice.ClientID, detail.ChinaName);
break;
case "dnumber":
colDNumber.Hidden = false;
colDNumber.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDNumber.ClientID, detail.ChinaName);
break;
case "dprice":
colDPrice.Hidden = false;
colDPrice.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDPrice.ClientID, detail.ChinaName);
break;
case "dmoney":
colDMoney.Hidden = false;
colDMoney.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDMoney.ClientID, detail.ChinaName);
break;
case "usage":
colUsage.Hidden = false;
colUsage.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colUsage.ClientID, detail.ChinaName);
break;
case "memo":
colMemo.Hidden = false;
colMemo.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colMemo.ClientID, detail.ChinaName);
break;
case "default1":
colDefault1.Hidden = false;
colDefault1.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault1.ClientID, detail.ChinaName);
break;
case "default2":
colDefault2.Hidden = false;
colDefault2.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault2.ClientID, detail.ChinaName);
break;
case "default3":
colDefault3.Hidden = false;
colDefault3.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault3.ClientID, detail.ChinaName);
break;
case "default4":
colDefault4.Hidden = false;
colDefault4.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault4.ClientID, detail.ChinaName);
break;
case "default5":
colDefault5.Hidden = false;
colDefault5.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault5.ClientID, detail.ChinaName);
break;
case "default6":
colDefault6.Hidden = false;
colDefault6.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault6.ClientID, detail.ChinaName);
break;
case "default7":
colDefault7.Hidden = false;
colDefault7.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault7.ClientID, detail.ChinaName);
break;
case "default8":
colDefault8.Hidden = false;
colDefault8.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault8.ClientID, detail.ChinaName);
break;
case "default9":
colDefault9.Hidden = false;
colDefault9.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault9.ClientID, detail.ChinaName);
break;
case "default10":
colDefault10.Hidden = false;
colDefault10.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault10.ClientID, detail.ChinaName);
break;
case "default11":
colDefault11.Hidden = false;
colDefault11.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault11.ClientID, detail.ChinaName);
break;
case "default12":
colDefault12.Hidden = false;
colDefault12.HeaderText = detail.ChinaName;
script += String.Format(headerScript, colDefault12.ClientID, detail.ChinaName);
break;
}
#endregion
}
PageContext.RegisterStartupScript(script);
|