This is a migrated thread and some comments may be shown as answers.

i want Headertemplate design with Table Formate

1 Answer 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kannadasan
Top achievements
Rank 1
Kannadasan asked on 15 Sep 2010, 03:17 PM

 

 

 

Dear Team,
 but I cant Find inner sever Table  control How To slove the problem..

with Regards,
S.Kannadasan

 

 

protected void Page_Init(object sender, System.EventArgs e)

 

{

DefineGridStructure();

 

 

}

 

private void DefineGridStructure()

 

{

 

RadGrid grid1 = new RadGrid();

 

grid1.ID =

"Comm";

 

grid1.AutoGenerateColumns =

false;

 

grid1.Skin =

"Vista";

 

 

DataTable CROWS = new DataTable();

 

 

DataTable CCOLUMNS = new DataTable();

 

 

DataTable Comercial = new DataTable();

 

CROWS = CommercialColumn();

 

for (int i = 0; i < CROWS.Rows.Count+1; i++)

 

{

 

DataColumn DC;

 

 

if (i == 0)

 

{

DC =

new DataColumn("VendorName");

 

}

 

 

else

 

 

 

{

DC =

new DataColumn(CROWS.Rows[i-1][0].ToString());

 

}

Comercial.Columns.Add(DC);

}

 

DataRow DR = null;

 

 

CCOLUMNS = CommercialRow();

 

for (int i = 0; i < CCOLUMNS.Rows.Count; i++)

 

{

DR = Comercial.NewRow();

 

for (int j = 0; j < Comercial.Columns.Count; j++)

 

{

 

if (j == 0)

 

{

DR[0] = CCOLUMNS.Rows[i][0].ToString();

}

 

else

 

 

 

{

 

DataRow[] DR1;

 

DR1 = CommercialPoint().Select(

"EvaluationText='" + CCOLUMNS.Rows[i][0].ToString() + "'");

 

DR[j] = DR1[0][

"Weightage"].ToString();

 

}

}

Comercial.Rows.Add(DR);

}

 

DR = Comercial.NewRow();

 

for (int i = 2; i < CCOLUMNS.Rows.Count; i++)

 

{

 

 

for (int j = 0; j < Comercial.Columns.Count; j++)

 

{

 

if (j == 0)

 

{

DR[0] =

"Total";

 

}

 

else

 

 

 

{

 

DR[j] =

"100%";

 

}

}

 

}

Comercial.Rows.Add(DR);

 

for (int j = 0; j < Comercial.Columns.Count; j++)

 

{

 

if (j == 0)

 

{

 

GridBoundColumn boundColumn1 = new GridBoundColumn();

 

boundColumn1.DataField =

"VendorName";

 

boundColumn1.UniqueName =

"VendorName";

 

boundColumn1.HeaderText =

"Vendor Name";

 

grid1.MasterTableView.Columns.Add(boundColumn1);

}

 

else

 

 

 

{

 

GridTemplateColumn templateColumn = new GridTemplateColumn();

 

templateColumn.UniqueName = Comercial.Columns[j].ColumnName;

templateColumn.HeaderTemplate =

new MyTemplate(Comercial.Columns[j].ColumnName);

 

templateColumn.HeaderText = Comercial.Columns[j].ColumnName;

templateColumn.DataField = Comercial.Columns[j].ColumnName;

templateColumn.ItemTemplate =

new MyTemplate1(Comercial.Columns[j].ColumnName);

 

grid1.MasterTableView.Columns.Add(templateColumn);

GridColumn.Add(Comercial.Columns[j].ColumnName);

}

}

grid1.DataSource = Comercial;

grid1.DataBind();

 

this.PlaceHolder2.Controls.Add(grid1);

 

}

 







protected

void btnApporved_Click(object sender, EventArgs e)

 

{

 

ArrayList SelectedColumn = new ArrayList();

 

 

RadGrid commgrid = (RadGrid)PlaceHolder2.Controls[0];

 

 

GridHeaderItem headerItem = (GridHeaderItem)commgrid.MasterTableView.GetItems(GridItemType.Header)[0];

 

 

foreach (string Columns in GridColumn)

 

{

 

CheckBox lb = (CheckBox)headerItem[Columns].Controls[0];

 

 

if (lb != null)

 

{

 

if (lb.Checked == true)

 

{

 

string Ids = lb.ID.ToString();

 

lb.Enabled =

false;

 

 

// SelectedColumn.Add(Ids);

 

StatusUpdated(Ids);

}

}

}

}

 



public

class MyTemplate : ITemplate

 

{

 

protected CheckBox boolValue;

 

 

private string colname;

 

 

Table TableName = new Table();

 

 

HtmlTable table = new HtmlTable();

 

 

public MyTemplate(string cName)

 

{

colname = cName;

}

 

public void InstantiateIn(System.Web.UI.Control container)

 

{

 

 

HtmlTableRow row = new HtmlTableRow();

 

 

HtmlTableRow row1 = new HtmlTableRow();

 

 

HtmlTableCell cell = new HtmlTableCell();

 

 

HtmlTableCell cell1 = new HtmlTableCell();

 

 

Label labelName = new Label();

 

 

//TableRow TR = new TableRow();

 

 

//TableRow TR1 = new TableRow();

 

 

//TableCell TC = new TableCell();

 

 

//TableCell TC1 = new TableCell();

 

labelName.Text =

"INITIAL OFFER/FINAL OFFER";

 

 

boolValue =

new CheckBox();

 

boolValue.ID = colname;

boolValue.Text =

"<a href='Commerical.aspx'>" + colname + "</a></br></br>";

 

 

// boolValue.DataBinding += new EventHandler(boolValue_DataBinding);

 

 

//TC.Controls.Add(boolValue);

 

 

//TC1.Controls.Add(labelName);

 

 

//TR.Cells.Add(TC);

 

 

//TR1.Cells.Add(TC1);

 

 

//TableName.Rows.Add(TR);

 

 

//TableName.Rows.Add(TR1);

 

 

 

//cell.Controls.Add(boolValue);

 

 

//cell1.Controls.Add(labelName);

 

 

//row.Cells.Add(cell);

 

 

//row1.Cells.Add(cell1);

 

 

//table.Rows.Add(row);

 

 

//table.Rows.Add(row1);

 

 

//container.Controls.Add(table);

 

container.Controls.Add(boolValue);

container.Controls.Add(labelName);

}

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Sep 2010, 03:04 PM
Hello Kannadasan,

Please checkout the following forum link which discusses similar scenario.

Thanks,
Princy.
Tags
Grid
Asked by
Kannadasan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or