Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Dynamic Template Column Sorting in DataGrid control

Reply
Thread Tools

Dynamic Template Column Sorting in DataGrid control

 
 
Vishal
Guest
Posts: n/a
 
      06-08-2004
Hi,

am facing a problem while using ASP.NET Datagrid Template Columns
generated dynamically.

Scenario:
-------------

1) I have a custom datagrid control class (inheriting from
System.Web.UI.WebControls.DataGrid).
In the constructor of this class i dynamically register the
OnSortCommand for the grid.

2) I have another custom CustomHeaderTemplate class inheriting from
ITemplate, which we are using to customize the header
column template for our custom DataGrid control.

3) In the BindData event of this class, am adding a LinkButton an
set the properties as follows.

---
DataGridItem container = (DataGridItem) pnl.NamingContainer;
LinkButton lb = new LinkButton();
lb.Text = "Employee Name";
lb.CommandName = "sort";
lb.CommandArgument = "EmpName"; //Name of the Column in the grid
DataSource
container.Controls.Add(tb);
---

4) In the aspx page containing the grid, set the HeaderTemplate of the
grid to this custom class

DataGridObject.HeaderTemplate = new CustomHeaderTemplate ();

5) The Link buttons appear fine in the column header, but when
clicked,
the OnSortCommand command of my custom datagrid does not fire.

Could anyone please let know what else needs to be done in order for
the Sort Command to fire in the case of dynamic DataGrid Template
Columns?

Thanks in advance.

Cheers,
Vishal Makhija
 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      06-08-2004
"Vishal" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hi,
>
> am facing a problem while using ASP.NET Datagrid Template Columns
> generated dynamically.
>
> Scenario:
> -------------
>
> 1) I have a custom datagrid control class (inheriting from
> System.Web.UI.WebControls.DataGrid).
> In the constructor of this class i dynamically register the
> OnSortCommand for the grid.
>
> 2) I have another custom CustomHeaderTemplate class inheriting from
> ITemplate, which we are using to customize the header
> column template for our custom DataGrid control.
>
> 3) In the BindData event of this class, am adding a LinkButton an
> set the properties as follows.
>
> ---
> DataGridItem container = (DataGridItem) pnl.NamingContainer;
> LinkButton lb = new LinkButton();
> lb.Text = "Employee Name";
> lb.CommandName = "sort";
> lb.CommandArgument = "EmpName"; //Name of the Column in the grid
> DataSource
> container.Controls.Add(tb);
> ---
>
> 4) In the aspx page containing the grid, set the HeaderTemplate of the
> grid to this custom class
>
> DataGridObject.HeaderTemplate = new CustomHeaderTemplate ();
>
> 5) The Link buttons appear fine in the column header, but when
> clicked,
> the OnSortCommand command of my custom datagrid does not fire.
>
> Could anyone please let know what else needs to be done in order for
> the Sort Command to fire in the case of dynamic DataGrid Template
> Columns?


Does the ItemCommand event fire? If so, check in the ItemCommand event for
CommandName == "sort" and then fire the SortCommand event yourself.
--
John Saunders
johnwsaundersiii at hotmail


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Static DataGrid - Dynamic Column Order - Sorting Issue Dan ASP .Net Datagrid Control 1 08-11-2006 07:05 PM
DataGrid loses view state if first column is a template column. Ken Varn ASP .Net 1 08-19-2005 02:54 PM
how to know if a datagrid column is a template column? Dexter ASP .Net 1 01-18-2005 01:45 PM
Dynamic Template Column Sorting in DataGrid control Vishal ASP .Net Web Controls 1 06-08-2004 12:48 PM
Dynamic Template Column Sorting in DataGrid control Vishal ASP .Net Datagrid Control 1 06-08-2004 12:48 PM



Advertisments