Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

Show only selected / one filed of Sharepoint list

$
0
0
  SPQuery oQuery = new SPQuery();
                oQuery.ViewFields = "<FieldRef Name='Country'/>";
                using (SPSite oSite = new SPSite(SPContext.Current.Site.Url))
                {
                    Guid lGUID = new Guid(ListGUID);
                    System.Data.DataTable oDataTblCollection = oSite.RootWeb.Lists[lGUID].GetItems(oQuery).GetDataTable();
                    gridView.DataSource = oDataTblCollection;
                    gridView.DataBind();
                }

my goal is to show only selected fields only to user say Country or it may be Country, city.

I have wrote above code but it is giving following output

which is fairly unexpected. I want to show only Country Column if user give Country name....

Thanks

Praveen


Viewing all articles
Browse latest Browse all 11508

Trending Articles