本文整理汇总了C#中System.Web.UI.WebControls.ObjectDataSource.DataBind方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectDataSource.DataBind方法的具体用法?C# ObjectDataSource.DataBind怎么用?C# ObjectDataSource.DataBind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.ObjectDataSource
的用法示例。
在下文中一共展示了ObjectDataSource.DataBind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fill
/// <summary>
/// Fills the specified gridview with a page of data.
/// </summary>
/// <param name="gv">The gridview.</param>
/// <param name="list">The single page of data.</param>
/// <param name="count">The total count (to work out number of pages).</param>
/// <param name="pageSize">Size of the page.</param>
public static void Fill(System.Web.UI.WebControls.GridView gv, IList<object> list, int count, int pageSize)
{
//create an ObjectDateSource object programmatically
ObjectDataSource ods = new ObjectDataSource();
ods.ID = "ods" + gv.ID;
ods.EnablePaging = gv.AllowPaging;
ods.TypeName = "ObjectAdaptor"; //can be a common base class
ods.SelectMethod = "Select";
ods.SelectCountMethod = "Count";
ods.StartRowIndexParameterName = "startRowIndex";
ods.MaximumRowsParameterName = "maximumRows";
ods.EnableViewState = false;
//when creating, inject the data into the table adaptor
ods.ObjectCreating += delegate(object sender, ObjectDataSourceEventArgs e)
{ e.ObjectInstance = new ObjectAdaptor(list, count); };
ods.DataBind();
gv.PageSize = pageSize;
gv.DataSource = ods;
gv.DataBind();
}