1
     "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>'Label1.Text'</Value>    </Eq></Where>";

I have not run this and checked yet, simply because I am quite sure it is not going to work. How exactly do I specify the syntax to compare and filter a list item[title] to a label.text Thanks

  • string query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + Label1.Text + "</Value></Eq></Where>"; – sssreddy Mar 21 '12 at 14:36
  • @sssreddy you should post that as an answer... since it is. – RJ Cuthbertson Mar 21 '12 at 14:39
2

The only thing you need to do to make that query valid, is ensure the Label1.Text uses the actual value, rather than the text 'Label1.Text'

In C# it would be something like

String camlQuery = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + Label1.Text + "</Value></Eq></Where>";
  • 2
    And make sure to Encode Label1.Text so it can't contain < and other chars which might leave you open for CAML injection attacks – Per Jakobsen Mar 21 '12 at 14:58

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.