Home All Groups Group Topic Archive Search About
Author
7 Mar 2006 9:24 AM
Arun
Datagrid sort event handler does not get fired
when dynamically creating/adding/removing columns to the datagrid

Thanks in advance for your answers

Arun

Author
7 Mar 2006 1:50 PM
Christopher Reed
You probably need to put the sort event handler in your code-behind,
probably in your Page_Init:

DataGrid1.SortCommand += new
DataGridSortCommandEventHandler(DataGrid1_SortCommand);

--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

Show quoteHide quote
"Arun" <nospam@nospam.com> wrote in message
news:e9GkxjcQGHA.3984@TK2MSFTNGP14.phx.gbl...
> Datagrid sort event handler does not get fired
> when dynamically creating/adding/removing columns to the datagrid
>
> Thanks in advance for your answers
>
> Arun
>
>
Author
7 Mar 2006 2:20 PM
Arun
Chris,

I have done that

Arun


Show quoteHide quote
"Christopher Reed" <carttu@nospam.nospam> wrote in message
news:eUvye4eQGHA.5116@TK2MSFTNGP10.phx.gbl...
> You probably need to put the sort event handler in your code-behind,
> probably in your Page_Init:
>
> DataGrid1.SortCommand += new
> DataGridSortCommandEventHandler(DataGrid1_SortCommand);
>
> --
> Christopher A. Reed
> "The oxen are slow, but the earth is patient."
>
> "Arun" <nospam@nospam.com> wrote in message
> news:e9GkxjcQGHA.3984@TK2MSFTNGP14.phx.gbl...
> > Datagrid sort event handler does not get fired
> > when dynamically creating/adding/removing columns to the datagrid
> >
> > Thanks in advance for your answers
> >
> > Arun
> >
> >
>
>
Author
8 Mar 2006 4:23 PM
Phillip Williams
Hi Arun,

I got your emails with the code that you used for creating the datagrid. 
Let’s continue the discussion on the forum.

You can search for previous threads where we discussed the issues to watch
for regarding dynamically created controls and the page lifecycle.  In
particular as it relates to the dependency of the function of those controls
on their ViewState.  Look in this article for the phases in which the
ViewState is loaded and saved:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-pageobjectmodel.asp

In your sample (whose code you emailed me) you can get it to work if you
were to move the databind from the button click event handling to the page
initialization (for one datagrid only in your case).  Once you see that, you
have to think of a different strategy to creating your DataGrid first (during
page.init) then sorting it (by re-binding the created controls to the new
sorted dataview) upon button click.

In other words, separate the DataBind method that you have into 2 methods;
1) one that adds the boundcolumns according to the DataTable structure and
adds the event handlers, 2)  another that databinds the data after sorting it
based on the selected sort key.

Show quoteHide quote
"Arun" wrote:

> Chris,
>
> I have done that
>
> Arun
>
>
> "Christopher Reed" <carttu@nospam.nospam> wrote in message
> news:eUvye4eQGHA.5116@TK2MSFTNGP10.phx.gbl...
> > You probably need to put the sort event handler in your code-behind,
> > probably in your Page_Init:
> >
> > DataGrid1.SortCommand += new
> > DataGridSortCommandEventHandler(DataGrid1_SortCommand);
> >
> > --
> > Christopher A. Reed
> > "The oxen are slow, but the earth is patient."
> >
> > "Arun" <nospam@nospam.com> wrote in message
> > news:e9GkxjcQGHA.3984@TK2MSFTNGP14.phx.gbl...
> > > Datagrid sort event handler does not get fired
> > > when dynamically creating/adding/removing columns to the datagrid
> > >
> > > Thanks in advance for your answers
> > >
> > > Arun
> > >
> > >
> >
> >
>
>
>