|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ASP.NET datagridDatagrid sort event handler does not get fired
when dynamically creating/adding/removing columns to the datagrid Thanks in advance for your answers Arun You probably need to put the sort event handler in your code-behind,
probably in your Page_Init: DataGrid1.SortCommand += new DataGridSortCommandEventHandler(DataGrid1_SortCommand); -- Show quoteHide quoteChristopher 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 > > 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 > > > > > > 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 > > > > > > > > > > > > >
GridView TemplateColumn
Retrieving Values from Hidden Fileds Inside Web Controls on PostBa Intercepting the GridView Datalist question... Panel Controls WebParts drag/drop problems PREVENT an ASP.Net page from posting back when the ENTER key press System.Web.UI.WebControls.Image control not refreshing Postback and return view Reaching elements within <asp:formview> control |
|||||||||||||||||||||||