Change Asp gridview snapping

I want to add some text to the boundfield assembly in the code behind, without writing any code in the code.

Example I get an "overflow" in a specific field, and I would like to display a "stack overflow", and if I get a "house", I want to display a "stack of houses"

Is there a property to put text behind or after what happens in a linked field?

+3
source share
3 answers

Use a special column.

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

notification

HtmlEncode = false

<asp:BoundField DataField="yourColumn" HeaderText="Your Header" DataFormatString="{0} overflow" HtmlEncode="false" SortExpression="GenCommission" />
+1
source

?

// instead of 
<asP:BoundField DataField="FieldName" />

// use
<asp:TemplateField>
<ItemTemplate>
    prefix <%# Eval("FieldName") %> suffix
</ItemTemplate>
</asp:TemplateField>
0

Source: https://habr.com/ru/post/1728915/


All Articles