PS: just a friendly remark for next time asking a similar question: this q. could receive more attention in the asp.net zone, as the GridView is an ASP.NET object (as is anything in an ASP.NET project).
Main Topics
Browse All TopicsHello,
Using .net 3.5 - ods to SQL 2005
I am pretty sure this should be simple, but I am not finding any solution to ToString.Replace for the value rendering of a DataColumn....
Here is the aspx Code where the datacolumn is called:
<asp:GridView ID="gvClients" runat="server" AutoGenerateColumns="False
DataKeyNames="clientID,cli
<Columns>
<asp:BoundField DataField="clientID" HeaderText="clientID" SortExpression="clientID"
Visible="False" />
<asp:TemplateField HeaderText="Clients" SortExpression="clientName
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("clientName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<asp:Label ID="lblClientName" runat="server" Font-Bold="True" Text='<%# Bind("clientName") %>'></asp:Label></td>
</tr>
Here is what I've attempted in the CodeBehind Which does not work.. The "Handles" piece is wrong, but, obviously, I don't know what it should be OR have it completely WRONG...
Please Help...
Protected Sub clientName(ByVal sender As System.Object, ByVal e As System.Web.UI.DataBinder) Handles ItemTemplate.lblClientName
Dim str1 As String = "clientName"
Dim RepStr As String = str1.Replace("*", " ")
Console.WriteLine("Replace
End Sub
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks Abel... & Thanks for the tip on where to post q's like this.
Sorry, I only included the code where the data column is called....
Don't know what you mean by " use the OnDataBound that each object has, including Label"
I, of course, went for your other suggestion to
Eval("clientname").Replace
but with that I get a Compilation Error "Option Strict On disallows late binding".
I made typing error: it is not OnDataBound, but OnDataBinding, which occurs "while databinding". Inside that event, you can use Eval just the same, it is a bit easier sometimes to code and keeps the aspx and vb code strictly separated.
Here's the same method using OnDataBinding event and putting the Eval in the code behind:
Business Accounts
Answer for Membership
by: abelPosted on 2009-08-16 at 06:00:59ID: 25108837
I don't see your full code, so I assume there's a reason for the whole table inside one cell ;-)
Replace("* ", " ")
, as that's not an event. Because the label is hidden in a naming container (the gridview and the gridviewrow), you can only add events by using the declarative syntax: OnDataBound="lblClientName _OnDataBou nd", and not use the Handles-statement.
There are two things to solve this: use the OnDataBound that each object has, including Label, or use the following line where it now says "Bind":
Eval("clientname").
and you should be sorted. I believe that's easier than using the code behind here.
-- Abel --
PS: there's no such thing as a Handles ItemTemplate.lblClientName
-- Abel --