how can dynamically change the text of a column in gridview ?

how to change the text of a dynamically bound column in gridview depending on data values ?
eg: in the below customer gridview , I do not want to show the  href at the bottom of the grid for microsoft i.e. when the  CompanyName is microsoft I do not want to show the delete hyperlink ? How can I achieve this ?

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="CustomerID" 
                <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" 
                    SortExpression="CustomerID" />
                <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" 
                    SortExpression="CompanyName" />
                <asp:BoundField DataField="ContactName" HeaderText="ContactName" 
                    SortExpression="ContactName" />
                <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" 
                    SortExpression="ContactTitle" />
                <asp:BoundField DataField="Address" HeaderText="Address" 
                    SortExpression="Address" />
                <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
                <asp:BoundField DataField="Region" HeaderText="Region" 
                    SortExpression="Region" />
                <asp:BoundField DataField="PostalCode" HeaderText="PostalCode" 
                    SortExpression="PostalCode" />
                    <itemstyle horizontalalign="Center"  Width="30px" />
                     <a href="internal.aspx?invoice_id=<%# Eval("cust_ID")%>"> delete</a>

Open in new window

Who is Participating?
If I understand the problem correctly, you want to hide the field if company MS has been selected.  If this is correct, then the following will give you some basic ideas how to do this:

Hope this helps.
Add a Composite column to you select statement, ie:
IIF(CompanyName == 'Microsoft', 'False', 'True') AS [Href_Visible

then add the following binding to the link:

<a href="internal.aspx?invoice_id=<%# Eval("cust_ID")%>" Visible='<%# Eval("Href_Visible")%>'> delete</a>

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.