This is a migrated thread and some comments may be shown as answers.

Grid - image in header with sorting.

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Grzesiek
Top achievements
Rank 2
Iron
Grzesiek asked on 16 Sep 2010, 11:44 AM
Hello!

In ItemDataBound event I have:
Dim header As GridHeaderItem = DirectCast(e.Item, GridHeaderItem)
       ' to set the height of the Grid Header
       header.Height = Unit.Pixel(20)
 
       ' to add an Image in the Grid Header
       Dim img As New ImageButton()
       img.ID = "imgCit"
       img.ImageUrl = "~/images/cit.png"
       header("cit_count").Controls.Add(img)
   End If

How can I now enable sorting?


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Sep 2010, 01:02 PM
Hello Grzesiek,

Instead of image use ImageButton with CommandName as 'Sort' and CommandArgument as the data field to achieve this functionality.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridHeaderItem)
        {
            GridHeaderItem header = (GridHeaderItem)e.Item;
            header.Height = Unit.Pixel(20);
            ImageButton imgbtn = new ImageButton();
            imgbtn.ImageUrl = "~/images/cit.png";
            imgbtn.CommandName = "Sort";
            imgbtn.CommandArgument = "cit_count";
            imgbtn.ID = "imgCit";
            header["cit_count"].Controls.Add(imgbtn);
        }
    }

Thanks,
Princy.
Tags
Grid
Asked by
Grzesiek
Top achievements
Rank 2
Iron
Answers by
Princy
Top achievements
Rank 2
Share this question
or