SPQuery for Retreving Basic Data i.e Text Field
#region SPQuery for Retreving Basic Data i.e Text Field
// Geting the Site Collection Reference using (SPSite curSite = new SPSite(http://hpkportal))
{
/// Geting the Web Application Reference
using (SPWeb curWeb = curSite.OpenWeb())
{
// Declaring the SPQuery fields
SPQuery curQuery = new SPQuery();
curQuery.Query = "
/// Seting the RowLimit will increase the performace of the Query
curQuery.RowLimit = 100;
SPList myList = curWeb.Lists["CustomListName"];
SPListItemCollection items = myList.GetItems(curQuery);
foreach (SPListItem i in items)
{
string CategoryTitle = i["Title"].ToString();
}
}
}
#endregion
SPQuery for Retreving Date Time Field
# region SPQuery for Retreving Date Time Field
/// Geting the Site Collection Reference
using (SPSite curSite = new SPSite(http://hpkportal))
{
/// Geting the Web Application Reference
using (SPWeb curWeb = curSite.OpenWeb())
{
// Declaring the SPQuery fields
SPQuery curQuery = new SPQuery();
curQuery.Query = "
/// Seting the RowLimit will increase the performace of the Query
curQuery.RowLimit = 100;
SPList myList = curWeb.Lists["CustomListName"];
SPListItemCollection items = myList.GetItems(curQuery);
foreach (SPListItem i in items)
{
DateTime CategoryCreatedDt = Convert.ToDateTime(i["Created Date"].ToString());
}
}
}
#endregion
SPQuery for Retreving Yes No Field
#region SPQuery for Retreving Yes No Field
/// Geting the Site Collection Reference
using (SPSite curSite = new SPSite(http://hpkportal))
{
/// Geting the Web Application Reference
using (SPWeb curWeb = curSite.OpenWeb())
{
// Declaring the SPQuery fields
SPQuery curQuery = new SPQuery();
curQuery.Query = "
/// Seting the RowLimit will increase the performace of the Query
curQuery.RowLimit = 100;
SPList myList = curWeb.Lists["CustomListName"];
SPListItemCollection items = myList.GetItems(curQuery);
foreach (SPListItem i in items)
{
byte CategoryType = Convert.ToByte(i["AreYouDone"].ToString());
}
}
}
#endregion
No comments:
Post a Comment