Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Change DataGrid Header Text and Still Sortable?

Status
Not open for further replies.

kvang

Programmer
Oct 7, 2005
129
US
My VB code is something like this:
Code:
Select Case e.Item.ItemType
            Case ListItemType.Header
                e.Item.Cells(6).Text = "Assessed Dollars MTD"
When I do this, it takes away my sort functionality for that column. How can I change the datagrid header text and still make the column sortable?
 
I think it's because your replacing controls with simple text. it doesn't look like you are preforming any logic so try this instead.

Code:
<asp:GridView ...>
   <Columns>
      <asp:DataBoundColumn HeaderText="foo" SortExpression="bar" ... />
   </Columns>
</asp:GridView>

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I've already specified the controls in the HTML code. I should've mention in my first post that I want to change the header text at runtime. The code below was what I was looking for:

Code:
dgFeeOverview.Columns(5).HeaderText = "Assessed Dollars MTD"

Thanks for you inputs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top