I want to pull datas from list with queries. I want to use many queries with C# code. And there is QueryString in C#. I want to use it. So how can i do this.

  • are you trying to use it in App ? or Visual Web Part ? that is Client side Object model or Server Object Model – Esaki Sep 28 '17 at 6:16

If you have a Visual Web Part and placed it in a page called http://myspsite/pages/WebPart.aspx then form the url with passing the Query String Parameter like


then to get this value from web part page PageLoad function call

string myParam = Request.QueryString["MyParam"];

this will give you the passed value in the query string. then you can pass this values in CamlQuery filters dynamically to retrieve list items.

| improve this answer | |

Use Request.QueryString to get querystring.


Build your query with dynamic values.

Sample code:

Server side object model:

SPQuery query = new SPQuery();
                query.Query = @"<Where><And>
                                    <Eq><FieldRef Name='ProjectCode' /><Value Type='Text'>"+queryValue+@"</Value></Eq>
                                        <Eq><FieldRef Name='AssignedTo' LookupId='True' /><Value Type='Int'>" + user.ID + "</Value></Eq>" + @"
                                        <Or><IsNull><FieldRef Name='TriggerFromTimerJob' /></IsNull><Eq><FieldRef Name='TriggerFromTimerJob' /><Value Type='Choice'>NO</Value></Eq></Or>

Client Side CAML:

CamlQuery query = new CamlQuery();
            query.ViewXml = @"<View><Query>
                                    <Eq><FieldRef Name='users' /><Value Type='User'>" + queryValue + @"</Value></Eq>

SharePoint CAML schema


| 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.