Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to Update List item programmatically

$
0
0

Hi,

I am trying to update all items of a list with a value.

I am using this code

SPList list = web.Lists["008"];
                    for (int i = 0;  i < list.ItemCount; i++)
                    {
                        SPListItem itemToAdd = list.Items.GetItemById(i);
                        itemToAdd["Seat Time"] = "45Min";
                        itemToAdd.Update();
                    }      

But this code gives error at list.items.getelementbyid(i);

But when i give the Id as shown in list (6 or 7) then it updates the list.

How could i solve this error?


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>