开发者

Modify Asp gridview boundfield

开发者 https://www.devze.com 2022-12-17 05:11 出处:网络
I want to add some text to a boundfield build in the code behind without writing any code in the code behind.

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 rec开发者_开发技巧eive "house" i want to display "stack house"

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


Use a custom column.

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


notice

HtmlEncode=false

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


Why not just use item template?

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

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号