EDN Admin
Well-known member
Hi,
trough a function a get back a Datarow from a certain Datatable ( linked to my database )
then I try to add the row with ImportRow and bind the DataTable to my DataGridView using the code below
<font color="#cc0000
Datarow RW = ArtikelInformation.getArtikel(nr);
DT.ImportRow(RW);
dataGridViewArtikel.DataSource = DT;</font>
Unfortunatly it only adds an empty row with no value in the columns.
Then I tried to add columns to the datatable using a function and code to add them:
<font color="#cc0000 addRow("nr", "Nr");
addRow("artikel_naam", "Naam");
addRow("artikel_omschrijving", "Omschrijving");
addRow("artikel_prijs", "Prijs");
addRow("artikel_aantal", "Aantal");
public void addRow(String naam, String caption){
DataColumn DC = new DataColumn();
DC.ColumnName = naam;
DC.Caption = caption;
DT.Columns.Add(DC);</font>
Now the function will work only it adds the columns too the ones I already had in my datagridview.
When I delete those colums it shows the columns wich are suppose to be added but the caption will not work, and an ugly database name is on top of my datagridview.
Any one an idea how I could fix this?
View the full article
trough a function a get back a Datarow from a certain Datatable ( linked to my database )
then I try to add the row with ImportRow and bind the DataTable to my DataGridView using the code below
<font color="#cc0000
Datarow RW = ArtikelInformation.getArtikel(nr);
DT.ImportRow(RW);
dataGridViewArtikel.DataSource = DT;</font>
Unfortunatly it only adds an empty row with no value in the columns.
Then I tried to add columns to the datatable using a function and code to add them:
<font color="#cc0000 addRow("nr", "Nr");
addRow("artikel_naam", "Naam");
addRow("artikel_omschrijving", "Omschrijving");
addRow("artikel_prijs", "Prijs");
addRow("artikel_aantal", "Aantal");
public void addRow(String naam, String caption){
DataColumn DC = new DataColumn();
DC.ColumnName = naam;
DC.Caption = caption;
DT.Columns.Add(DC);</font>
Now the function will work only it adds the columns too the ones I already had in my datagridview.
When I delete those colums it shows the columns wich are suppose to be added but the caption will not work, and an ugly database name is on top of my datagridview.
Any one an idea how I could fix this?
View the full article