Question

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.

Was it helpful?

Solution

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>";
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top