By this way we can override datagridview col string: and put in this format Config1, Config2 etc….!
DataSet ds = new DataSet();
ds.ReadXml(@"D:\test\a.xml");
for (int i = 1; i <= ds.Tables[0].Rows.Count; i++)
{
ds.Tables[0].Rows[i - 1][0] = "Config" + i;
}
dataGridView1.DataSource = ds.Tables[0];
In my case, my datagridview col has already filled data from a xml file after that I want to override by above method (I’m not using any dataset to read xml file)
This is my approach & it’s completely wrong… any help??
private void writefunction()
{
for (int i = 1; i <= dataGridView3.Columns["id"].Index; i++)
{
dataGridView3.Columns[i - 1][0] = "Config" + i;
}
}
As far as I know, you cannot manually modify the contents of a GridView. To make any changes, you have to modify the corresponding data in the data source and bind the GridView again.
To achieve what you are looking for, modify the value in the DataTable and set the DataSorce property of the GridView to modified DataTable and call DataBind method.