SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite objSite = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb objWeb = objSite.OpenWeb())
{
SPList AppdetailsList = objWeb.Lists.TryGetList("OppositionDetails");
if (AppdetailsList != null)
{
SPQuery ListDataQuery = new SPQuery();
//ListDataQuery.Query = "<Where><And><Contains><FieldRef Name='IPR'/><Value Type='Text'>" + ddlIPR.SelectedValue.ToString() + "</Value></Contains><Or></Contains></Or></And></Where><OrderBy><FieldRef Name='Modified' Ascending='FALSE' /></OrderBy>";
ListDataQuery.Query = "<Where><Eq><FieldRef Name='IPR' /> <Value Type='Text'>" + ddlIPR.SelectedValue.ToString() + "</Value></Eq></Where>";
//ListDataQuery.Query = "<Where><And><Contains><FieldRef Name='IPR'/><Value Type='Text'>" + ddlIPR.SelectedValue.ToString() + "</Value></Contains><Or><Contains><FieldRef Name='Domain' /><Value Type='Text'>" + ddlDomain.SelectedValue.ToString() + "</Value></Contains><Contains><FieldRef Name='Products' /><Value Type='Text'>" + ddlProduct.SelectedValue.ToString() + "</Value></Contains></Or></And></Where><OrderBy><FieldRef Name='Modified' Ascending='FALSE' /></OrderBy>";
SPListItemCollection myColl = AppdetailsList.GetItems(ListDataQuery);
DataTable table;
table = new DataTable();
table.Columns.Add("OppNo", typeof(string));
table.Columns.Add("OIPR", typeof(string));
table.Columns.Add("ODomain", typeof(string));
table.Columns.Add("OCountry", typeof(string));
table.Columns.Add("OProducts", typeof(string));
table.Columns.Add("OPPStatus", typeof(string));
// Create rows for each splistitem
DataRow row;
foreach (SPListItem item in myColl)
{
row = table.Rows.Add();
//row["Title"] = result.Name;
row["OppNo"] = item["OppositionNo"];
row["OIPR"] = item["IPR"];
row["ODomain"] = item["Domain"];
row["OCountry"] = item["Countries"];
row["OProducts"] = item["Products"];
row["OPPStatus"] = item["Status"];
// row["URL"] = "Your site url" + result.Url; //here need to append the site url to the item url
}
GrdOpposition.DataSource = table.DefaultView;
GrdOpposition.DataBind();
}
{
using (SPSite objSite = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb objWeb = objSite.OpenWeb())
{
SPList AppdetailsList = objWeb.Lists.TryGetList("OppositionDetails");
if (AppdetailsList != null)
{
SPQuery ListDataQuery = new SPQuery();
//ListDataQuery.Query = "<Where><And><Contains><FieldRef Name='IPR'/><Value Type='Text'>" + ddlIPR.SelectedValue.ToString() + "</Value></Contains><Or></Contains></Or></And></Where><OrderBy><FieldRef Name='Modified' Ascending='FALSE' /></OrderBy>";
ListDataQuery.Query = "<Where><Eq><FieldRef Name='IPR' /> <Value Type='Text'>" + ddlIPR.SelectedValue.ToString() + "</Value></Eq></Where>";
//ListDataQuery.Query = "<Where><And><Contains><FieldRef Name='IPR'/><Value Type='Text'>" + ddlIPR.SelectedValue.ToString() + "</Value></Contains><Or><Contains><FieldRef Name='Domain' /><Value Type='Text'>" + ddlDomain.SelectedValue.ToString() + "</Value></Contains><Contains><FieldRef Name='Products' /><Value Type='Text'>" + ddlProduct.SelectedValue.ToString() + "</Value></Contains></Or></And></Where><OrderBy><FieldRef Name='Modified' Ascending='FALSE' /></OrderBy>";
SPListItemCollection myColl = AppdetailsList.GetItems(ListDataQuery);
DataTable table;
table = new DataTable();
table.Columns.Add("OppNo", typeof(string));
table.Columns.Add("OIPR", typeof(string));
table.Columns.Add("ODomain", typeof(string));
table.Columns.Add("OCountry", typeof(string));
table.Columns.Add("OProducts", typeof(string));
table.Columns.Add("OPPStatus", typeof(string));
// Create rows for each splistitem
DataRow row;
foreach (SPListItem item in myColl)
{
row = table.Rows.Add();
//row["Title"] = result.Name;
row["OppNo"] = item["OppositionNo"];
row["OIPR"] = item["IPR"];
row["ODomain"] = item["Domain"];
row["OCountry"] = item["Countries"];
row["OProducts"] = item["Products"];
row["OPPStatus"] = item["Status"];
// row["URL"] = "Your site url" + result.Url; //here need to append the site url to the item url
}
GrdOpposition.DataSource = table.DefaultView;
GrdOpposition.DataBind();
}
No comments:
Post a Comment