Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public void DynamicNewTitle()
        {
            
            TableNew.BorderWidth = 2;
            TableNew.GridLines = GridLines.Both;
            string sql = string.Format("SELECT TitleMaster.TitleId, TitleMaster.ProjectTitle, DomainMaster.DomainName, TechnologyMaster.TechnologyName FROM DomainMaster INNER JOIN TitleMaster ON DomainMaster.DomainId = TitleMaster.DomainId AND DomainMaster.DomainId = TitleMaster.DomainId INNER JOIN TechnologyMaster ON TitleMaster.TechnologyId = TechnologyMaster.TechnologyId where TitleMaster.TitleId ='{0}'", id.ToString());
            DataTable tab = new DataTable();
            tab = csobj.Do_NonTransaction(sql);
            string[] h = { "TitleId", "ProjectTitle", "DomainName", "TechnologyName" };
            TableHeaderRow hr = new TableHeaderRow();
            for (int s = 0; s <h.length;>            {
                TableHeaderCell hc = new TableHeaderCell();
                hc.Text = h[s];
                hr.Controls.Add(hc);   
             
            }
            TableNew.Controls.Add(hr);
            
            string[] cols = { "TitleId", "ProjectTitle", "DomainName", "TechnologyName" };
            for (int s = 0; s < tab.Rows.Count; s++)
            {
                TableRow row = new TableRow();
                for (int t = 0; t < cols.Length; t++)
                {
                    TableCell cell = new TableCell();
                    cell.Text = tab.Rows[s][cols[t]].ToString();
                    row.Controls.Add(cell);
                }
               
                TableNew.Controls.Add(row);
            }


it displaying headers many as my datatable rows count

i need only once header
what should i have to change
Posted
Updated 7-Nov-12 19:55pm
v2
Comments
Sanjay K. Gupta 8-Nov-12 1:56am    
Call your method in Row_Created when Header is being created
Lakshmimsridhar 8-Nov-12 1:59am    
didnt got where i have to change tell me.

1 solution

private void AddHeader()
{
string[] h = { "TitleId", "ProjectTitle", "DomainName", "TechnologyName" };
TableHeaderRow hr = new TableHeaderRow();
for (int s = 0; s < h.Length; s++)
{
TableHeaderCell hc = new TableHeaderCell();
hc.Text = h[s];
hr.Controls.Add(hc);

}
TableNew.Controls.Add(hr);
}

i created this header method and called this got the output:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900