Hi experts,
I want to do a custom datagrid which has my custom style of pager. What
I want in the pager is a drop down list which list all the available
pages.
I inherits my custom control from the original datagrid. The idea is to
remove all original child from the pager row, add my own. So I override
the OnItemCreated, get the pager row and put my customization in..
Code:
protected override void OnItemCreated(DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Pager)
{
BuildPager(e.Item); //my customization
}
base.OnItemCreated (e);
}
private void BuildPager(DataGridItem row)
{
int totalPage = (int)Math.Ceiling(this.VirtualItemCount /
this.PageSize);
TableCell cell = row.Cells[0];
cell.Controls.Clear();
DropDownList ddlPages = new DropDownList();
cell.Controls.Add(ddlPages);
for (int i=1; i<=totalPage; i++)
ddlPages.Items.Add(i.ToString());
ddlPages.AutoPostBack = true;
ddlPages.SelectedIndexChanged += new
EventHandler(ddlPages_SelectedIndexChanged);
.
.
It came out displayed correctly. But I can't seem to capture the
SelectedIndexChanged event? How come?
I've tried adding a Button and LinkButton in exactly the same way.
Events from them can be captured without problem.
Can anybody please explain? Thank you...