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" 
            DataSourceID="SqlDataSource1">
            <Columns>
                <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" />
 
	       <asp:BoundField>
                    <itemstyle horizontalalign="Center"  Width="30px" />
                    <itemtemplate>
                     <a href="internal.aspx?invoice_id=<%# Eval("cust_ID")%>"> delete</a>
                </itemtemplate>
               </asp:BoundField>
  
             
	    </Columns>
 
</asp:GridView>

Open in new window

tech_questionAsked:
Who is Participating?
 
newbiealCommented:
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:
http://www.netomatix.com/development/GridViewHideColumn.aspx

Hope this helps.
0
 
oobaylyCommented:
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

0
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.