Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 20th, 2006, 12:06 AM
Registered User
 
Join Date: Dec 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dinamically Adding DropDownList Into DataGridItem

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...







Similar Threads
Thread Thread Starter Forum Replies Last Post
adding dropdownlist item to a textbox alto ASP.NET 2.0 Basics 2 May 24th, 2007 01:14 AM
Fit the row height dinamically in a datagrid Lukas C# 1 June 7th, 2006 03:06 AM
Adding DropDownList to Datagrid muskaanbajaj VB.NET 0 September 5th, 2005 04:29 AM
Adding an element to a binded DropDownlist mahulda ASP.NET 1.0 and 1.1 Basics 3 March 10th, 2004 03:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.