Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i have created on e dataGrid at design time and create its column at runtime as

<sdk:datagrid canusersortcolumns="True" autogeneratecolumns="False" grid.row="2" horizontalalignment="Left" margin="18,0,0,0" name="grd_Enterprise_summary" verticalalignment="Top" xmlns:sdk="#unknown">

           </sdk:datagrid>

C#
private DataGridColumn CreateColumn(string property)
        {
            return new DataGridTextColumn()
            {
                CanUserSort = true,
                Header = property,
                SortMemberPath = property,
                IsReadOnly = true,
                Binding = new Binding()
                {
                    Converter = _rowIndexConverter,
                    ConverterParameter = property
                }
            };
        }

Datagrid binding is done as
Dictionary<string,> firstRow1 = new Dictionary<string,>();

               this.AddColumnToGrid(grd_Enterprise_summary, (IEnumerable<dictionary><string,>>)record1);
               grd_Enterprise_summary.ItemsSource = record1;</dictionary>

when i click on header sorting is not performed .

What should i do for this ?

thanks in advance
Posted
Updated 4-Aug-11 22:45pm
v2
Comments
walterhevedeich 5-Aug-11 4:38am    
Try adding CanUserSortColumns property to your new column and set it to true. Haven't tried it yet though.
Member 8100743 5-Aug-11 4:44am    
Hi walterhevedeich,
CanUserSortColumn is added but still having issue

1 solution

I can see the ItemsSource for the datagrid is missing.
Define the itemsource and they try again.
 
Share this answer
 
Comments
Member 8100743 5-Aug-11 4:45am    
I have Sets ItemSource as
Dictionary<string, object=""> firstRow1 = new Dictionary<string, object="">();

this.AddColumnToGrid(grd_Enterprise_summary, (IEnumerable<dictionary<string, object="">>)record1);
grd_Enterprise_summary.ItemsSource = record1;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900