Tuesday, January 19, 2010
Thursday, January 14, 2010
How set distinct value to dropdown list
private void FillInt()
{
using (SPSite site = SPContext.Current.Site)
{
using (SPWeb web = site.OpenWeb())
{
web.Lists.IncludeRootFolder = true;
SPList ChartList = web.Lists["Organization Charts"];
//query.Query = "USA ";
SPQuery query = new SPQuery();
query.Query = " ";
SPListItemCollection listItems = ChartList.GetItems(query);
foreach (SPListItem listItem in listItems)
{
FillDropDownList(listItem, ddlGroup, "field");
}
}
}
}
private void FillDropDownList(SPListItem listItem,DropDownList ddlTemp, string fieldName)
{
if (null == ddlTemp.Items.FindByText(listItem[fieldName].ToString()))
{
ListItem ThisItem = new ListItem();
ThisItem.Text = listItem[fieldName].ToString();
ThisItem.Value = listItem[fieldName].ToString();
ddlTemp.Items.Add(ThisItem);
}
}
{
using (SPSite site = SPContext.Current.Site)
{
using (SPWeb web = site.OpenWeb())
{
web.Lists.IncludeRootFolder = true;
SPList ChartList = web.Lists["Organization Charts"];
//query.Query = "
SPQuery query = new SPQuery();
query.Query = "
SPListItemCollection listItems = ChartList.GetItems(query);
foreach (SPListItem listItem in listItems)
{
FillDropDownList(listItem, ddlGroup, "field");
}
}
}
}
private void FillDropDownList(SPListItem listItem,DropDownList ddlTemp, string fieldName)
{
if (null == ddlTemp.Items.FindByText(listItem[fieldName].ToString()))
{
ListItem ThisItem = new ListItem();
ThisItem.Text = listItem[fieldName].ToString();
ThisItem.Value = listItem[fieldName].ToString();
ddlTemp.Items.Add(ThisItem);
}
}
How to get distinct value from CAML query
Many times, we face a challenge to get unique rows froma CAML query. The main problem is that CAML does not have any feature to get the distinct rows in one go.
Way Around:
We all know that CAML query returns SPListItemCollection and we can convert the outcome to data table also.
We can convert the resultant datatable to dataview and again convert the dataview to datatable by using ToTable and arguments :
Distinct = true
and column name
So..
suppose we have SPWeb object as 'web' so
DataTable DT= web.GetSiteData(qry);
DataView v = new DataView(tbl);
return v.ToTable(true, "Type");
This code snippets returns the distinct rows by comparing column name "Type".
copy from: http://firstblogofvarun.blogspot.com/2009/05/how-to-get-distinct-value-from-caml.html
Way Around:
We all know that CAML query returns SPListItemCollection and we can convert the outcome to data table also.
We can convert the resultant datatable to dataview and again convert the dataview to datatable by using ToTable and arguments :
Distinct = true
and column name
So..
suppose we have SPWeb object as 'web' so
DataTable DT= web.GetSiteData(qry);
DataView v = new DataView(tbl);
return v.ToTable(true, "Type");
This code snippets returns the distinct rows by comparing column name "Type".
copy from: http://firstblogofvarun.blogspot.com/2009/05/how-to-get-distinct-value-from-caml.html
Thursday, January 7, 2010
Wednesday, January 6, 2010
copy assembly from GAC
use the command line to copy the file from (for an assembly called system.core, version 3.5.0.0, culture=neutral, publickeytoken=b77a5c561934089)
Final command:
copy C:\windows\assembly\GAC_MSIL\system.core\3.5.0.0__b77a5c561934089\system.core.dll c:\
Final command:
copy C:\windows\assembly\GAC_MSIL\system.core\3.5.0.0__b77a5c561934089\system.core.dll c:\
Friday, September 25, 2009
Debugging Web Parts - a full explanation of the requirements
http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=60
CallStack=true
debug=”true”
level=”Full”
mode=”Off” in the node
CallStack=true
debug=”true”
level=”Full”
mode=”Off” in the
Subscribe to:
Posts (Atom)