Dev P
Dev P

Reputation: 1187

Displaying CAML query results?

I am trying to execute an CAML query based on a conditional if statement. So if a variable in this case "xapthresult" is equal to "BT ADSL" then query will be executed. Below is a snippet of the code:

//Executing the correct query based on a if condition for BT ADSL
if(xpathresult == "BT ADSL")
{

//Creating the CAML query to perfomr the query on the list to find the required values
SPQuery query = new SPQuery();


//try to find items in this list that matches the result of the XPATH query performed
//earlier
//in this case "BT/Standard"
string camlquery = @"<Query>
<Where>
<Eq>
<FieldRef Name='Vendor_x0020_Product_x0020_Name'/>
<Value Type='Text'>" + xpathresultBTADSL + @"</Value>
</Eq>
</Where>  
</Query>";

query.Query = camlquery;
query.ViewFields = "<FieldRef Name='Fabric_x0020_Name'/>
<FieldRefName='Defined_x0020_For/><FieldRef name='MPLS'/>"; 
//selecting only the required fields from the CAML query

SPListItemCollection listItemCollection = list.GetItems(query);


}

I would like to know how to display results of the query in a of a webpart!

Any help would be greatly appreciated,

Thanks

Upvotes: 1

Views: 939

Answers (1)

int32
int32

Reputation: 1687

you could use the SPGridView control.

Upvotes: 1

Related Questions