本文整理汇总了C#中System.Web.UI.WebControls.ObjectDataSource.Select方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectDataSource.Select方法的具体用法?C# ObjectDataSource.Select怎么用?C# ObjectDataSource.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.ObjectDataSource
的用法示例。
在下文中一共展示了ObjectDataSource.Select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateReport
internal XtraReport GenerateReport(ASPxGridView ASPxGridView1, ObjectDataSource ObjectDataSource1)
{
report = new XtraReport();
report.Landscape = true;
report.PaperKind = System.Drawing.Printing.PaperKind.Letter;
//InitDataSource(ObjectDataSource1);
DataView dv = new DataView();
DataTable dt = new DataTable();
dv = ObjectDataSource1.Select() as DataView; //.Select(DataSourceSelectArguments.Empty) as DataView;
dt = dv.ToTable();
report.DataSource = dt;
InitDetailsAndPageHeader(ASPxGridView1);
InitSortings(ASPxGridView1);
InitGroupHeaders(ASPxGridView1);
InitFilters(ASPxGridView1);
InitTotalSummaries(ASPxGridView1);
return report;
}
示例2: CreateColumnAsDropDown
private DropDownList CreateColumnAsDropDown(TableCell td, DataColumn _dc, DropDownList ddl)
{
ddl = new DropDownList();
ddl.ID = "ddl" + _dc.ColumnName;
ddl.AppendDataBoundItems = true;
ddl.Width = Unit.Pixel(_dc.MaxLength * PixelsPerCharacter);
// locate the right DataTextField and DataSource
int iPosDDLCol = DropDownListColumns.FindIndex( c => c.Equals( _dc.ColumnName ) );
// prepare the data source to be bound
ObjectDataSource objODS = new ObjectDataSource();
objODS.TypeName = DataSourceTypeName[ iPosDDLCol ];
objODS.SelectMethod = DataSourceSelectMethod[ iPosDDLCol ];
//objODS.SelectParameters.Add(
objODS.Select();
// execute the data bind
ddl.DataValueField = DropDownValueField[ iPosDDLCol ];
ddl.DataTextField = DropDownTextField[ iPosDDLCol ];
ddl.DataSource = objODS;
ddl.DataBind();
Fields.Add(ddl.ID, _dc.ColumnName);
if (_dc.ReadOnly)
ddl.CssClass = CssClassPrimaryKey;
ddl.ToolTip = GetDefaultTooltip(_dc);
td.Controls.Add(ddl);
ddl.DataBinding += new EventHandler(ddl_DataBinding);
return ddl;
}
示例3: InitDataSource
void InitDataSource(ObjectDataSource aspDataSource)
{
DataView dv = new DataView();
DataTable dt = new DataTable();
dv = (DataView)aspDataSource.Select();
//dv = aspDataSource.Select("") as DataView;
//dv = aspDataSource.Select(DataSourceSelectArguments.Empty) as DataView;
dt = dv.ToTable();
report.DataSource = dt;
}
示例4: CreateAndAssignTemplates
private void CreateAndAssignTemplates()
{
_objGV.Columns.Clear();
if( _objODDataSource == null)
_objODDataSource = new OrderedDictionary();
// create template for commands such as Edit and Delete and assign it to the gridview
TemplateField objLinkButtonTemplates = new TemplateField();
objLinkButtonTemplates.ItemTemplate = new DynamicGridViewTemplate(ListItemType.Item, "...", "Command");
objLinkButtonTemplates.HeaderTemplate = new DynamicGridViewTemplate(ListItemType.Header, "...", "Command");
objLinkButtonTemplates.EditItemTemplate = new DynamicGridViewTemplate(ListItemType.EditItem, "...", "Command");
_objGV.Columns.Add(objLinkButtonTemplates);
if (_objDT != null)
{
// set the primary key if available
if (_objDT.PrimaryKey.Length > 0)
_objGV.DataKeyNames = new string[] { _objDT.PrimaryKey[0].ColumnName };
foreach (DataColumn objDC in _objDT.Columns)
{
// for each column, create header/display/editing templates
TemplateField objFieldTemplate = new TemplateField();
// determine the size of the column
string strType = objDC.DataType.Name;
int iSize = objDC.MaxLength;
switch (strType)
{
case "Decimal":
case "Int64": iSize = 19; break;
case "DateTime": iSize = 22; break;
case "Int16": iSize = 5; break;
case "Int32": iSize = 10; break;
}
// default the size to 50
if (iSize < 0)
iSize = 50;
// check whether the column is a foreign key
string strFK = "", strFKTable = "";
if (objDC.ExtendedProperties.ContainsKey("ForeignKey"))
{
strFK = objDC.ExtendedProperties["ForeignKey"].ToString();
strFKTable = objDC.ExtendedProperties["ForeignKeyTable"].ToString();
// create data source for the dropdownlist
ObjectDataSource objODS;
if (_objODDataSource.Contains(strFKTable))
objODS = (ObjectDataSource)_objODDataSource[strFKTable];
else
{
// get value samples from the first/last rows
string strMaxValue = _objDT.Compute( string.Concat( "MAX(", objDC.ColumnName, ")" ), "" ).ToString();
string strMinValue = _objDT.Compute( string.Concat( "MIN(", objDC.ColumnName, ")" ), "" ).ToString();
objODS = new ObjectDataSource();
// caches data until inactive for 60 seconds
objODS.EnableCaching = true;
objODS.CacheExpirationPolicy = DataSourceCacheExpiry.Sliding;
objODS.CacheDuration = 60;
objODS.TypeName = DataSourceTypeName;
objODS.SelectMethod = DataSourceSelectMethod;
objODS.SelectParameters.Add("strTableName", strFKTable);
objODS.SelectParameters.Add("strKey", strFK);
// give the sample value so the query will try to get 500 rows surrounding that value
objODS.SelectParameters.Add("strMinValue", strMinValue);
objODS.SelectParameters.Add("strMaxValue", strMaxValue);
objODS.Select();
_objODDataSource.Add(strFKTable, objODS);
}
// create display/editing templates that will become dropdownlists
objFieldTemplate.ItemTemplate = new DynamicGridViewTemplate(ListItemType.Item, objDC.ColumnName, strType
, iSize, strFK, strFKTable, objODS);
objFieldTemplate.EditItemTemplate = new DynamicGridViewTemplate(ListItemType.EditItem, objDC.ColumnName
, strType, iSize, strFK, strFKTable, objODS);
}
else
{
objFieldTemplate.ItemTemplate = new DynamicGridViewTemplate(ListItemType.Item, objDC.ColumnName, strType, iSize);
objFieldTemplate.EditItemTemplate = new DynamicGridViewTemplate(ListItemType.EditItem, objDC.ColumnName, strType, iSize);
}
// create header/display/editing templates
objFieldTemplate.HeaderTemplate = new DynamicGridViewTemplate(ListItemType.Header, objDC.ColumnName, strType);
// assign templates to the gridview
_objGV.Columns.Add(objFieldTemplate);
} // end foreach
} // end if
string strSessionGVName = string.Concat("DGVS_", _objGV.ID, "_Dictionary");
//.........这里部分代码省略.........