本文整理汇总了C#中System.Web.UI.WebControls.PagedDataSource.SetItemCountFromPageIndex方法的典型用法代码示例。如果您正苦于以下问题:C# PagedDataSource.SetItemCountFromPageIndex方法的具体用法?C# PagedDataSource.SetItemCountFromPageIndex怎么用?C# PagedDataSource.SetItemCountFromPageIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.PagedDataSource
的用法示例。
在下文中一共展示了PagedDataSource.SetItemCountFromPageIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateChildControls
protected override int CreateChildControls (IEnumerable data, bool dataBinding)
{
PagedDataSource dataSource;
if (dataBinding) {
DataSourceView view = GetData ();
dataSource = new PagedDataSource ();
dataSource.DataSource = data;
if (AllowPaging) {
dataSource.AllowPaging = true;
dataSource.PageSize = PageSize;
dataSource.CurrentPageIndex = PageIndex;
if (view.CanPage) {
dataSource.AllowServerPaging = true;
if (view.CanRetrieveTotalRowCount)
dataSource.VirtualCount = SelectArguments.TotalRowCount;
else {
dataSource.DataSourceView = view;
dataSource.DataSourceSelectArguments = SelectArguments;
dataSource.SetItemCountFromPageIndex (PageIndex + PagerSettings.PageButtonCount);
}
}
}
pageCount = dataSource.PageCount;
}
else
{
dataSource = new PagedDataSource ();
dataSource.DataSource = data;
if (AllowPaging) {
dataSource.AllowPaging = true;
dataSource.PageSize = PageSize;
dataSource.CurrentPageIndex = PageIndex;
}
}
bool showPager = AllowPaging && (PageCount > 1);
Controls.Clear ();
table = CreateChildTable ();
Controls.Add (table);
ArrayList list = new ArrayList ();
ArrayList keyList = new ArrayList ();
// Creates the set of fields to show
ICollection fieldCollection = CreateColumns (dataSource, dataBinding);
DataControlField[] fields = new DataControlField [fieldCollection.Count];
fieldCollection.CopyTo (fields, 0);
foreach (DataControlField field in fields) {
field.Initialize (AllowSorting, this);
if (EnableSortingAndPagingCallbacks)
field.ValidateSupportsCallback ();
}
// Main table creation
if (showPager && PagerSettings.Position == PagerPosition.Top || PagerSettings.Position == PagerPosition.TopAndBottom) {
topPagerRow = CreatePagerRow (fields.Length, dataSource);
table.Rows.Add (topPagerRow);
}
if (ShowHeader) {
headerRow = CreateRow (0, 0, DataControlRowType.Header, DataControlRowState.Normal);
table.Rows.Add (headerRow);
InitializeRow (headerRow, fields);
}
foreach (object obj in dataSource) {
DataControlRowState rstate = GetRowState (list.Count);
GridViewRow row = CreateRow (list.Count, list.Count, DataControlRowType.DataRow, rstate);
row.DataItem = obj;
list.Add (row);
table.Rows.Add (row);
InitializeRow (row, fields);
if (dataBinding) {
// row.DataBind ();
OnRowDataBound (new GridViewRowEventArgs (row));
if (EditIndex == row.RowIndex)
oldEditValues = new DataKey (GetRowValues (row, false, true));
keyList.Add (new DataKey (CreateRowDataKey (row), DataKeyNames));
} else {
if (EditIndex == row.RowIndex)
oldEditValues = new DataKey (new OrderedDictionary ());
keyList.Add (new DataKey (new OrderedDictionary (), DataKeyNames));
}
if (list.Count >= PageSize)
break;
}
if (list.Count == 0)
table.Rows.Add (CreateEmptyrRow (fields.Length));
if (ShowFooter) {
footerRow = CreateRow (0, 0, DataControlRowType.Footer, DataControlRowState.Normal);
//.........这里部分代码省略.........
示例2: CreateChildControls
protected override int CreateChildControls (IEnumerable data, bool dataBinding)
{
PagedDataSource dataSource;
if (dataBinding) {
DataSourceView view = GetData ();
dataSource = new PagedDataSource ();
dataSource.DataSource = data;
if (AllowPaging) {
dataSource.AllowPaging = true;
dataSource.PageSize = 1;
dataSource.CurrentPageIndex = PageIndex;
if (view.CanPage) {
dataSource.AllowServerPaging = true;
if (view.CanRetrieveTotalRowCount)
dataSource.VirtualCount = SelectArguments.TotalRowCount;
else {
dataSource.DataSourceView = view;
dataSource.DataSourceSelectArguments = SelectArguments;
dataSource.SetItemCountFromPageIndex (PageIndex + PagerSettings.PageButtonCount);
}
}
}
pageCount = dataSource.PageCount;
}
else
{
dataSource = new PagedDataSource ();
dataSource.DataSource = data;
if (AllowPaging) {
dataSource.AllowPaging = true;
dataSource.PageSize = 1;
dataSource.CurrentPageIndex = PageIndex;
}
}
bool showPager = AllowPaging && (PageCount > 1);
Controls.Clear ();
table = CreateTable ();
Controls.Add (table);
ArrayList list = new ArrayList ();
if (!Page.IsPostBack)
currentMode = DefaultMode;
// Gets the current data item
IEnumerator e = dataSource.GetEnumerator ();
if (e.MoveNext ())
dataItem = e.Current;
else
dataItem = null;
// Creates the set of fields to show
ICollection fieldCollection = CreateFieldSet (dataItem, dataBinding);
DataControlField[] fields = new DataControlField [fieldCollection.Count];
fieldCollection.CopyTo (fields, 0);
foreach (DataControlField field in fields) {
field.Initialize (false, this);
if (EnablePagingCallbacks)
field.ValidateSupportsCallback ();
}
// Main table creation
if (HeaderText.Length != 0 || headerTemplate != null) {
headerRow = CreateRow (-1, DataControlRowType.Header, DataControlRowState.Normal);
DataControlFieldCell cell = new DataControlFieldCell (null);
cell.ColumnSpan = 2;
if (headerTemplate != null)
headerTemplate.InstantiateIn (cell);
else
cell.Text = HeaderText;
headerRow.Cells.Add (cell);
table.Rows.Add (headerRow);
}
if (showPager && PagerSettings.Position == PagerPosition.Top || PagerSettings.Position == PagerPosition.TopAndBottom) {
topPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
InitializePager (topPagerRow, dataSource);
table.Rows.Add (topPagerRow);
}
if (dataSource.Count > 0) {
foreach (DataControlField field in fields) {
DataControlRowState rstate = GetRowState (list.Count);
DetailsViewRow row = CreateRow (list.Count, DataControlRowType.DataRow, rstate);
InitializeRow (row, field);
table.Rows.Add (row);
list.Add (row);
if (commandField == field)
commandRow = row;
//.........这里部分代码省略.........
示例3: CreateChildControls
protected override int CreateChildControls (IEnumerable data, bool dataBinding)
{
PagedDataSource dataSource;
if (dataBinding) {
DataSourceView view = GetData ();
dataSource = new PagedDataSource ();
dataSource.DataSource = data;
if (AllowPaging) {
dataSource.AllowPaging = true;
dataSource.PageSize = 1;
dataSource.CurrentPageIndex = PageIndex;
if (view.CanPage) {
dataSource.AllowServerPaging = true;
if (view.CanRetrieveTotalRowCount)
dataSource.VirtualCount = SelectArguments.TotalRowCount;
else {
dataSource.DataSourceView = view;
dataSource.DataSourceSelectArguments = SelectArguments;
dataSource.SetItemCountFromPageIndex (PageIndex + PagerSettings.PageButtonCount);
}
}
}
pageCount = dataSource.PageCount;
}
else
{
dataSource = new PagedDataSource ();
dataSource.DataSource = data;
if (AllowPaging) {
dataSource.AllowPaging = true;
dataSource.PageSize = 1;
dataSource.CurrentPageIndex = PageIndex;
}
}
bool showPager = AllowPaging && (PageCount > 1);
dataSourceCount = dataSource.Count;
Controls.Clear ();
table = CreateTable ();
Controls.Add (table);
if (!Page.IsPostBack)
currentMode = DefaultMode;
// Gets the current data item
IEnumerator e = dataSource.GetEnumerator ();
if (e.MoveNext ())
dataItem = e.Current;
else
dataItem = null;
// Main table creation
if (HeaderText.Length != 0 || headerTemplate != null) {
headerRow = CreateRow (-1, DataControlRowType.Header, DataControlRowState.Normal);
InitializeRow (headerRow);
table.Rows.Add (headerRow);
}
if (showPager && PagerSettings.Position == PagerPosition.Top || PagerSettings.Position == PagerPosition.TopAndBottom) {
topPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
InitializePager (topPagerRow, dataSource);
table.Rows.Add (topPagerRow);
}
if (dataSourceCount > 0) {
DataControlRowState rstate = GetRowState ();
itemRow = CreateRow (0, DataControlRowType.DataRow, rstate);
InitializeRow (itemRow);
table.Rows.Add (itemRow);
if (!dataBinding) {
if (CurrentMode == FormViewMode.Edit)
oldEditValues = new DataKey (new OrderedDictionary ());
key = new DataKey (new OrderedDictionary (), DataKeyNames);
}
} else {
itemRow = CreateRow (-1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal);
table.Rows.Add (itemRow);
InitializeRow (itemRow);
}
if (showPager && PagerSettings.Position == PagerPosition.Bottom || PagerSettings.Position == PagerPosition.TopAndBottom) {
bottomPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
InitializePager (bottomPagerRow, dataSource);
table.Rows.Add (bottomPagerRow);
}
if (FooterText.Length != 0 || footerTemplate != null) {
footerRow = CreateRow (-1, DataControlRowType.Footer, DataControlRowState.Normal);
InitializeRow (footerRow);
table.Rows.Add (footerRow);
}
if (dataBinding)
//.........这里部分代码省略.........