rename sortable column header in griedview (c#)

Hello experts,

I have a Gridview with sorting enabled, so the column headers are links. I'd like to change the text of the links in the header at runtime, for example in the RowDataBound event, while keeping the sorting functionality.

Thanks in advance,
Kernelv12
LVL 3
kernelv12Asked:
Who is Participating?
 
the_paabCommented:
Try this:

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            ((LinkButton)(e.Row.Cells[0].Controls[0])).Text = "othertext";
        }
    }
0
 
kernelv12Author Commented:
Thank you the_paab, nice and simple...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.