Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.
     "<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

share|improve this question
    
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
    
@sssreddy Thanks –  user7400 Mar 21 '12 at 14:43

1 Answer 1

up vote 2 down vote accepted

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>";
share|improve this answer
    
Thanks for the reply –  user7400 Mar 21 '12 at 14:43
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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