/// <summary>
/// 生成Gridview的绑定列
/// </summary>
/// <param name="gv"></param>
private void TreeViewBindMethod(GridView gv)
{
//gv.Columns.Clear();
for (int colNum = gv.Columns.Count - 1; colNum >= 0; colNum--)
{
if (gv.Columns[colNum].GetType().FullName.ToString() == "System.Web.UI.WebControls.BoundField")
{
gv.Columns.RemoveAt(colNum);
}
}
BoundField fieldStationName = new BoundField();
fieldStationName.DataField = "STATIONID";
fieldStationName.HeaderText = "变电站名称";
fieldStationName.Visible = false;
gv.Columns.Add(fieldStationName);
BoundField fieldDeviceName = new BoundField();
fieldDeviceName.DataField = "devicetypename";
fieldDeviceName.HeaderText = "设备名称";
fieldDeviceName.Visible = false;
gv.Columns.Add(fieldDeviceName);
BoundField fieldObjName = new BoundField();
fieldObjName.DataField = "objid";
fieldObjName.HeaderText = "主设备名称";
fieldObjName.Visible = false;
gv.Columns.Add(fieldObjName);
BoundField fieldDateTime = new BoundField();
fieldDateTime.DataField = "datetime";
fieldDateTime.HeaderText = "时间";
gv.Columns.Add(fieldDateTime);
if (dtDga != null && dtDga.Rows.Count > 0)
{
for (int i = 0; i < dtDga.Rows.Count; i++)
{
BoundField field = new BoundField();
field.DataField = dtDga.Rows[i][1].ToString().Trim();
field.HeaderText = dtDga.Rows[i][1].ToString().Trim();
gv.Columns.Add(field);
}
}
//HyperLinkField hlf = new HyperLinkField();
//hlf.HeaderText = "诊断";
////string[] canshu = new string[4] { "stationid", "datetime", "devicetypename", "objid" };
////hlf.DataNavigateUrlFields = canshu;
////hlf.DataNavigateUrlFormatString = "~/diagnose/DiagnoseGeneral.aspx?stationid={0}&datetime={1}&devicetypename={2}&objid={3}";
//hlf.DataNavigateUrlFields = new string[] { "stationid" };
//hlf.DataNavigateUrlFormatString = "~/diagnose/DiagnoseGeneral.aspx?stationid={0}";
////hlf.NavigateUrl = "~/diagnose/DiagnoseGeneral.aspx?stationid={0}&datetime={1}}";
//hlf.Text = "诊断";
//gv.Columns.Add(hlf);
}