mardi 6 janvier 2015

How to add custom fields programmatically to my sharepoint list?



I have a Sharepoint list called ListA, it has almost 100k rows and some columns.


For the purpose of my program, I want to add some custom fields to that list (just temporarily for the code use, these fields are not to be added to the actual list).


So, what I did is get the datatable from that list and then add columns to that datatable. Perform operations on that datatable, so my actual list is not affected.


Now, my problem is that I want to add a column that will contain the row index of the corresponding row. Any idea how to achieve that? Right now, I am doing the following:



DataColumn col = new DataColumn();
col.AutoIncrement = true;
col.AutoIncrementSeed = 1;
col.AutoIncrementStep = 1;
dt.Columns.Add(col);
dt.Merge(spList.DataTable);


But i don't find this very performance-efficient as the merging takes much time. Is there any other better way to achieve this?








0 commentaires:

Enregistrer un commentaire