Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Column headers
Message
De
29/08/2005 22:12:09
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Column headers
Divers
Thread ID:
01045005
Message ID:
01045005
Vues:
59
While creating a grid programmatically (not based on a table), I am having trouble setting the column headers.

Here is part of my code:
// Instantiate objects
Ds = new DataSet();
Dt = new DataTable();
for (i=0; i<numColumnas; i++)
{
  Dc = new DataColumn();
  Dc.ColumnName = "Col_" + (i).ToString();
  Dc.Caption = "x " + (i).ToString();
  Dc.DataType = System.Type.GetType("System.String");
  Dt.Columns.Add(Dc);
  ...
}
// Add tables to DataSet
Ds.Tables.Add(Dt);

// Assign to grid
dgLista.DataSource = Ds;
dgLista.DataMember = Ds.Tables[0].TableName;
...
The trouble is, the caption remains the same as the column name, for example, "Col_1", when I expect "x 1".
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform