Search code examples
asp.netgridviewtextboundfield

Modify Asp gridview boundfield


I want to add some text to a boundfield build in the code behind without writing any code in the code behind.

example I receive "overflow" in a specific field, and i'd like to display "stack overflow" and if i receive "house" i want to display "stack house"

is there a property to put text behind or after whatever comes in the boundfield ?


Solution

  • Use a custom column.

      <asp:TemplateField HeaderText="MyColumn">
        <ItemTemplate> 
             stack <asp:Literal runat="server" Text="<%#Eval("myField")%>" />
        </ItemTemplate>
      </asp:TemplateField>