Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Update a field in a specific Item query

$
0
0

Hi guys ,

i want to update  a specific field in a List Item  .. below is my code

                SPSite site1 = new SPSite("http://spserver2010/sites/Testing/ProjectTest");
                SPWeb web = site1.OpenWeb();
                SPList list = web.Lists["Project Site Link"];
               SPQuery query = new SPQuery();
                 query.Query ="<Query> <Where> <Eq> <FieldRef Name='Project_x0020_Name' /> <Value Type='String'>TextBox2.Text</Value></Eq> </Where></Query>";
                SPListItemCollection collListItems = list.GetItems(query);

                
               foreach (SPListItem item in collListItems)
                {

                    item["Project_x0020_Description"] = "http://spserver2010/sites/Testing/ProjectTest" + TextBox2.Text;
                    item.Update();
                }

The problem is that the code update all the item in the Project_x0020_Description colum and not only the item where'Project_x0020_Name' is equal TextBox2.Text..

Any idea

Thanx!


Viewing all articles
Browse latest Browse all 11571

Trending Articles



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