Re: ItemDataBound not Firing on Repeater
Brady Kelly <[email protected]> Fri, 7 Sep 2007 18:27:43 +0200
| Newsgroups | gmane.comp.windows.devel.dotnet.web |
|---|---|
| Message-ID | <[email protected]> |
This is my code in the page hosting my control. The pgnTest.DataSource and
pgnTest.DataBind calls refer to the methods described below, from my
previous post:
protected void Page_Load(object sender, EventArgs e)
{
// pgnTest is a Paginator control on this test page.
DataTable emps = SqlDataProvider.GetEmployees();
pgnTest.DataSource = emps;
pgnTest.DataBind();
}
public partial class Paginator : System.Web.UI.UserControl
{
PagingManager pagingManager = new PagingManager();
protected void Page_Load(object sender, EventArgs e)
{
// This doesn't hook up the event, while using the attribute
on the Repeater does.
rptPageButtons.ItemDataBound += new
RepeaterItemEventHandler(rptPageButtons_ItemDataBound);
}
protected void rptPageButtons_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
Button btnPage = e.Item.FindControl("pageButton") as Button;
DataRowView drv = e.Item.DataItem as DataRowView;
if (drv != null)
{
btnPage.Attributes.Add("PageKey",
drv["PageKey"].ToString());
btnPage.Text = drv["PageDesc"].ToString();
}
}
public DataTable DataSource
{
set
{
pagingManager.MaxPageSize = 15;
pagingManager.PaginateDataTable(value);
rptPageButtons.DataSource = pagingManager.PagesDataTable;
}
}
public new void DataBind()
{
rptPageButtons.DataBind();
}
}
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com