hello :) i have a datagridview populated from a bindingsource and i've tried in many ways to add an autonumber column. I've found some solutions on the Internet, but still doesn't work.:( here's my code:
SqlDataAdapter dataAdapter2 = new SqlDataAdapter("SELECT * FROM categorie_discount_adaos", conn);
dataAdapter2.Fill(dataSet, "categorie_discount_adaos");
categdaGridView.AutoGenerateColumns = false;
categdaBS.DataSource = dataSet.Tables["categorie_discount_adaos"];
categdaGridView.DataSource = categdaBS;
categdaGridView.Columns["denumire_categorie"].DataPropertyName = "denumire_categorie";
categdaGridView.Columns["tip_categorie"].DataPropertyName = "tip_categorie";
categdaGridView.Columns["procent"].DataPropertyName = "procent";
//i've tried this
int cellnum = 0;
int rownum = 0;
foreach (DataGridViewRow row in categdaGridView.Rows)
{
cellnum = cellnum + 1;
categdaGridView.Rows[rownum].Cells[0].Value = cellnum;
rownum = rownum + 1;
}