2

If in the html table header, I would use:

<th class="titleclass" width="200"><span>Header Text</span> <sup><a href="#link"><span style="font-size: 12px">1</span></a></sup></th>

How can I use the same header text in bound field of asp.net gridview. I tried the following:

<asp:boundcolumn 
    visible="True" 
    datafield="Column1" 
    headertext="<span>Header Text</span> <sup><a href='#link'><span style='font-size: 12px'>1</span></a></sup>" 
    HeaderStyle-CssClass="titleclass">
    <itemstyle horizontalalign="Left"></itemstyle>
</asp:boundcolumn>

This is not working. It says "There is not source available for the current location" and the style for my header text is not applied (but the style for the superfix number 1 is applied). Any thoughts?

2
  • Why must it be a BoundColumn versus a TemplateColumn? Commented Jun 19, 2013 at 21:19
  • What is the HTML rendered to the page for the tr & th tags? And what says "There is not source available for the current location", that sounds like a binding problem. Commented Jun 20, 2013 at 1:17

2 Answers 2

1

Convert your field to Template: 'Edit Columns - Select needed field - Convert to Template'

Edit the header template as desired.

Refer to this link: http://msdn.microsoft.com/en-us/library/bb288032.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

I complete forgot about template columns. Thanks for reminding me
0

You can use the HeaderStyle Property of the gridview.

<asp:GridView ID="GridView1" runat="server"> <HeaderStyle CssClass="titleclass"/> . . .

Or you can do it from within your ASP.NET code,

GridView1.Columns[0].HeaderStyle.CssClass = "titleClass";

Hope this helps

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.