|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
sorting in a datagridHi,
I am developing a composite control, so I am writing all my code in a *.cs file. One of the component in my composite control is a datagrid. The datagrid is populated from a dataview by using DataBind(). The user should be able to sort the datagrid my clicking the header of the columns. Anyone has a sample of this? It would be really helpful for me. I only want to write c# code to do this. Thanks Julia Hi
It is working when I use AutoGenerateColumns = true; but not when I use AutoGenerateColumns = false;. Any ideas? /Julia Show quoteHide quote "Julia" wrote: > Hi, > > I am developing a composite control, so I am writing all my code in a *.cs > file. One of the component in my composite control is a datagrid. The > datagrid is populated from a dataview by using DataBind(). The user should be > able to sort the datagrid my clicking the header of the columns. Anyone has > a sample of this? It would be really helpful for me. I only want to write c# > code to do this. > > Thanks > Julia hi Julia,
you need to attach to the SortCommand handler for your datagrid in code and then do what you need to do in this event when sorting is enabled on the grid. One possible mistake i can think of why you sorting is not working on your grid is possibly because when you set autogenerate columns to false, you are probably also trying to set a templatecolumn in the HeaderTemplate <HeaderTemplate></HeaderTemplate> . In this case make sure you add a control in your HeaderTemplate that can postback like a button control or a linkbutton, imagebutton etc.. try these resources : http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.allowsorting.aspx http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.sortcommand.aspx good luck, Alessandro Zifiglio Show quoteHide quote "Julia" <Ju***@discussions.microsoft.com> ha scritto nel messaggio news:05B39BEA-5EC8-439C-8FDC-959077D1C5F5@microsoft.com... > Hi > > It is working when I use AutoGenerateColumns = true; but not when I use > AutoGenerateColumns = false;. > > Any ideas? > > /Julia > > "Julia" wrote: > >> Hi, >> >> I am developing a composite control, so I am writing all my code in a >> *.cs >> file. One of the component in my composite control is a datagrid. The >> datagrid is populated from a dataview by using DataBind(). The user >> should be >> able to sort the datagrid my clicking the header of the columns. Anyone >> has >> a sample of this? It would be really helpful for me. I only want to write >> c# >> code to do this. >> >> Thanks >> Julia If you're using BoundColumns, don't forget to set the SortExpression
property for each column. -- Show quoteHide quoteRiki "Julia" <Ju***@discussions.microsoft.com> wrote in message news:05B39BEA-5EC8-439C-8FDC-959077D1C5F5@microsoft.com... > Hi > > It is working when I use AutoGenerateColumns = true; but not when I use > AutoGenerateColumns = false;. > > Any ideas? > > /Julia > > "Julia" wrote: > >> Hi, >> >> I am developing a composite control, so I am writing all my code in a >> *.cs >> file. One of the component in my composite control is a datagrid. The >> datagrid is populated from a dataview by using DataBind(). The user >> should be >> able to sort the datagrid my clicking the header of the columns. Anyone >> has >> a sample of this? It would be really helpful for me. I only want to write >> c# >> code to do this. >> >> Thanks >> Julia
GridView override InitializePager columnSpan problem when using BoundField Visible=false
back to calling page Need help on validation on a group of controls Copying A Control Not As A Reference Page / UserControl OnInit Problem Where is Page.RegisterClientScriptBlock Available? how to raise SelectedIndexChange event? Determining item count of databound DropDownList checkbox weird Problem Control in template does not bubble events |
|||||||||||||||||||||||