0

How to apply SuperScript to BoundField. script is like

<fieldSet ..
    ..
    <asp:GridView...
    ..
        <Columns>
            **<asp:BoundField DataField="Price" HeaderText="Price" .../>**
        </Column>
    <asp:gridView>
</fieldSet>  

I would like to display column Price as "Price1" to user. Note: in Price1, 1 is SuperScript in red color.

Thanks.

Shegit Brahm
  • 725
  • 2
  • 9
  • 22

1 Answers1

1

Use a template field instead

<asp:TemplateField>
    <ItemTemplate>
        <%# Eval("Price") %><sup>1</sup>
    </ItemTemplate>
 </asp:TemplateField>

EDIT

If you can't change to a template field then your best bet is to alter the text after it has loaded. A grid view has an OnLoad event you can hook into so in your grid view you can have

<asp:GridView OnLoad="GridView_Load"

And then in your code you can do something like this

public void GridView_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        foreach (GridViewRow row in GridView.Rows)
        {
            row.Cells[0].Text += " <sup>1</sup>";
        }
    }
}
Kevin Main
  • 2,334
  • 17
  • 28
  • Thanks Kevin for reply. Its maintenance project so I can not change existing BoundField.Have to find a way to apply superScript in BoundField. – StackUnderFlow May 03 '12 at 11:52