Hi,
I am using a DataGridView to store some data. At runtime,I want to add an extra new column "ID" and insert numbers serially starting from 1 till the number of rows present at runtime in the DataTable . How can I achieve this ??
Hi,
I am using a DataGridView to store some data. At runtime,I want to add an extra new column "ID" and insert numbers serially starting from 1 till the number of rows present at runtime in the DataTable . How can I achieve this ??
Sneha,
This is the issues for .NET section not our products, please check it on the MSDN website,
Thanks,
Scott,
Hi,
Sorry for incomplete information. Actually I am using a dataTable to store the data dynamically using the piece of code below.
layerfile.Open();
DataTable db = new DataTable();
db = layerfile.QueryTools.ExecuteQuery(txt_qfinal.Text);
layerfile.Close();
Here at the time of execution of query, I had to add a column " ID " which will contain values serially from 1 to last row of dataTable. I tried to add the column but the result was:
Name
ISD_CODE
ID
US
123
CANADA
456
UK
789
1
2
3
But I want the following result:
NAME
ISD_CODE
ID
US
123
1
CANADA
456
2
UK
789
3
Sneha,
I would like to ask you what’s the sql statements you used? Can you show me that? I guessed maybe your sql statement had any problems.
Thanks,
Scott,
Hi,
The SQL statement differs dynamically. The above table is just an example.
I wanted to add the column "ID" to every dataTable db created on execution of the query.
The query results work fine.
layerfile.Open();
DataTable db = new DataTable();
db = layerfile.QueryTools.ExecuteQuery(txt_qfinal.Text);
layerfile.Close();
After these statement I added
DataColumn dcol= new DataColumn();
db.Columns.Add(dcol);
dcol.Autincrement;
Sneha,
Actually, this is not our product’s issuss, it is related to the datagrid object, if you didn’t find out the problem, please give us your whole solution to us and we can track the problem based on your application and give you the solution on that.
Thanks,
Scott,