protected void Page_Init(object sender, EventArgs e)
{
string strPlant = string.Empty;
if (Session["PlantVal"] != null)
{
strPlant = Session["PlantVal"].ToString();
if (strPlant != null && strPlant.Trim().Length > 0)
{
DefineGridStructure(strPlant);
}
}
}
public DataTable DefineGridStructure(string strPlant)
{
dtRakeLoad = new DataTable();
Plants oplant = new Plants();
GridBoundColumn boundColumn = new GridBoundColumn();
dtRakeLoad .Columns.Add("Date", typeof(string));
this.RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "Date";
boundColumn.UniqueName = "Date";
boundColumn.HeaderText = "Date";
boundColumn.DataType = System.Type.GetType("System.String");
GridBoundColumn boundColumn1;
DataSet ds = new DataSet();
ds = oplant.GetChildCode(strPlant);
string strChildCode = ds.Tables[0].Rows[0][0].ToString();
Session["ChildCode"] = strChildCode;
DataTable dtgroup = new DataTable();
string strgroup = strChildCode;
dtgroup = oplant.GetPlant(strgroup);
DataRow dtRow = null;
if (dtgroup != null)
{
foreach (DataRow dr in dtgroup.Rows)
{
String sPlantName = "";
String sPlantCode = "";
sPlantCode = dr["PlantCode"].ToString();
dtRakeLoad .Columns.Add(sPlantCode, typeof(string));
boundColumn1 = new GridBoundColumn();
this.RadGrid1.MasterTableView.Columns.Add(boundColumn1);
boundColumn1.DataField = sPlantCode;
boundColumn1.UniqueName = sPlantCode;
boundColumn1.HeaderText = sPlantCode;
boundColumn1.DataType = System.Type.GetType("System.String");
}
}
string templateColumnName = "Total";
GridTemplateColumn templateColumn = new GridTemplateColumn();
dtRakeLoad .Columns.Add("Total", typeof(string));
templateColumn.ItemTemplate = new MyTemplate1(templateColumnName);
this.RadGrid1.MasterTableView.Columns.Add(templateColumn);
templateColumn.UniqueName = "Total";
templateColumn.DataField = "Total";
templateColumn.HeaderText = "Total";
templateColumn.DataType = System.Type.GetType("System.String");
DataTable dtport = new DataTable();
dtport = oplant.GetPortName(strgroup);
GridTemplateColumn templateColumn1;
if (dtport != null)
{
foreach (DataRow dr in dtport.Rows)
{
string sPortName = "";
string sPortCode = "";
sPortName = dr["PortName"].ToString();
sPortCode = dr["PortCode"].ToString();
dtRakeLoad .Columns.Add(sPortName, typeof(string));
templateColumn1 = new GridTemplateColumn();
this.RadGrid1.MasterTableView.Columns.Add(templateColumn1);
templateColumn1.ItemTemplate = new TemplatePort(sPortCode);
templateColumn1.DataField = sPortName;
templateColumn1.UniqueName = sPortName;
templateColumn1.HeaderText = sPortName;
templateColumn1.DataType = System.Type.GetType("System.String");
}
}
string templateColumnName2 = "UnAllot";
GridTemplateColumn templateColumn2 = new GridTemplateColumn();
dtRakeLoad.Columns.Add("UnAllot", typeof(string));
templateColumn2.ItemTemplate = new MyTemplate3(templateColumnName2);
this.RadGrid1.MasterTableView.Columns.Add(templateColumn2);
templateColumn2.UniqueName = "Unallot";
templateColumn2.HeaderText = "UnAllot";
templateColumn2.DataField = "UnAllot";
templateColumn2.DataType = System.Type.GetType("System.String");
string templateColumnName3 = "Rake";
GridTemplateColumn templateColumn3 = new GridTemplateColumn();
dtRakeLoad.Columns.Add("Rake", typeof(string));
templateColumn3.ItemTemplate = new MyTemplate4(templateColumnName3);
this.RadGrid1.MasterTableView.Columns.Add(templateColumn3);
templateColumn3.DataField = "Rake";
templateColumn3.UniqueName = "Rake";
templateColumn3.HeaderText = "Rake";
templateColumn3.DataField = "Rake";
templateColumn3.DataType = System.Type.GetType("System.String");
RadGrid1.DataSource = dtRakeLoad;
return dtRakeLoad;
}