Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid and hyperlink

Status
Not open for further replies.

smsinger3

Programmer
Oct 5, 2000
192
US
Hello all. I have a column on a datagrid which I display a hyperlink. I am doing this just fine (see code below). However, I only want to display the link when a certain database field is null. Anyone know how I can do this?

Thanks!

SteveS

Here is what I have so far:

<asp:datagrid id=&quot;dgrdServerAvail&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot; GridLines=&quot;Both&quot; BorderColor=&quot;Gray&quot; BorderWidth=&quot;1&quot; CellPadding=&quot;6&quot; CellSpacing=&quot;0&quot; EnableViewState=&quot;true&quot;>
<HeaderStyle Font-Bold=&quot;True&quot; HorizontalAlign=&quot;Center&quot; BackColor=&quot;LightGray&quot;></HeaderStyle>
<Columns>
<asp:BoundColumn DataField=&quot;SRVR_CODE&quot; Visible=&quot;False&quot;></asp:BoundColumn>
<asp:TemplateColumn HeaderText=&quot;Check<Br>Out&quot;>
<ItemTemplate>
<center>
<asp:checkbox ID=&quot;chkCheckout&quot; Runat=&quot;server&quot;></asp:checkbox></center>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField=&quot;SRVR_SERVER_NAME&quot; HeaderText=&quot;Server Name&quot;></asp:BoundColumn>
<asp:HyperLinkColumn HeaderText=&quot;Previous<Br>Checkout<br>Info&quot; DataNavigateUrlField=&quot;COIT_CODE&quot; DataNavigateUrlFormatString=&quot;CheckInOutDetail.aspx?id={0}&quot; Text=&quot;view&quot;></asp:HyperLinkColumn>
</Columns>
</asp:datagrid>
 
You can do it in your DB. If you're using a Hyperlink Field, which looks like you are, don't write to the field unless the other field is null. Use a trigger if its SQL Server, or other means if another DBMS.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top