I have my Listinstance in Sisual Studio every time i Deploy the Guid Id changes to a new value


We says its first time, next time i deploy it has other values in the ID , how should i solve this because i use an Spsitedataquery were i want to query my lists , there i specifie my listid but the id always changes how should i solve it?


Instead of specifying listID in Spsitedataquery specify List TemplateID

SPSiteDataQuery dataQuery = new SPSiteDataQuery();
                dataQuery.Webs = "<Webs Scope=\"SiteCollection\">";
                dataQuery.Lists = "<Lists ServerTemplate=\"10000\" />";
                dataQuery.ViewFields = "<FieldRef Name=\"Title\" />";
                string where ="<Where><Eq>";
                where += "<FieldRef Name=\"EmployeeID\"/>";
                where += "<Value Type='Integer'>" + txtEmpId.Text + "</Value>";
                where += "</Eq></Where>";

                dataQuery.Query = where;
                DataTable dt = web.GetSiteData(dataQuery);

Disadvantage:In this case you will be querying all the lists with ServerTemplate=10000.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.