473,322 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

adding text to a bound field in a gridview

How do I add static text to a bound field in a gridview? For instance, I
want the following label in a gridview to be displayed as
"Smith: Exempt"
"Jones: Exempt"
etc.
<asp:Label ID="Label1" runat="server" Text='<%# Bind("LastName")
%>'></asp:Label>
Dec 6 '07 #1
1 15595
Hi there,

Two ways:

1. Set DataFormatString property, i.e:
<columns>
<asp:BoundField DataField="LastName" DataFormatString="{0}: Exempt"/>
</columns>

2. Use template field instead:
<columns>
<asp:TemplateField HeaderText="Whatever">
<ItemTemplate>
<%# Eval("LastName") %>: Exempt
</ItemTemplate>
</asp:TemplateField>
</columns>

Hope it helps
--
Milosz
"tester" wrote:
How do I add static text to a bound field in a gridview? For instance, I
want the following label in a gridview to be displayed as
"Smith: Exempt"
"Jones: Exempt"
etc.
<asp:Label ID="Label1" runat="server" Text='<%# Bind("LastName")
%>'></asp:Label>
Dec 6 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Megan | last post by:
Hi everybody- I have 2 tables, Hearings and Rulings. Both have primary keys called, CaseID, that are autonumbers. I don't want both tables to have the same autonumber. For example, if Hearings...
2
by: pittster | last post by:
Hi, I've bound a Gridview control to the GetFiles method Here is a code snippet: DirectoryInfo objDi = new DirectoryInfo(Server.MapPath("./somepath")); FileInfo arrFileInfo =...
1
by: shapper | last post by:
Hello, How can I make a GridView Bond Field to display its text in Bold? I couldn't find any CssClass or Bold property in the Bound Field. Thanks, Miguel
3
by: Metalzed | last post by:
Hi I want to have a log so in my table i got a TEXT field called LOGG. I want to update this field with new data by adding more text to field. I am using MS SQL 'test' + 'test' doesn't...
2
by: BD | last post by:
Hi, How can I get the name of the bound field from a control that has binding to a BindingSource at runtime. For example: txtID.DataBindings.Add("Text", bdgSourceTest, "ID"); txtID is a...
1
by: shapper | last post by:
Hello, I have looping through a GridView rows as follows: For Each gvrLevel As GridViewRow In gvLevels.Rows ... Next gvrLevel How can I get the value of a BoundField named "Description" in...
2
by: Kbalz | last post by:
I have a user control that has a gridview in it. I am dynamically setting up its datasource and columns based on an XML file. I have everything done except adding columns to the gridview, so that...
0
by: Mike | last post by:
So here's the situation (.NET 2.0 btw): I have a form, and on this form is a textbox among many other databound controls. The textbox is bound to a field in a data table via the Text property. ...
1
by: bkberg05 | last post by:
Hi - I have a form called 'Order'. It has a subform called 'Order_Detail'. On the 'Order_Detail', I have many records for each order record. On the footer of the subform (it's a continuous...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.