I have a Gridview ItemTemplate which displays company info as follows
The problem is that if a column is blank the <br/> is still appended so the
cell is taller then it needs to be and I have less space to display more
rows. And in this data there are a lot of rows one or more blank columns.
There is one solution for condition like this use this tag to check condition
<%#Eval("FieldName")==DBNull.Value? "" : "<br/>" %>
I have one field in DB that have name of pdf file and i have to show download link if there is data in this field, here is the solution
<ItemTemplate>
<asp:Label ID="WEmployerLabel" runat="server" Text='<%# Bind("Employer")
%>'></asp:Label><br />
<asp:Label ID="WAddress1Label" runat="server" Text='<%#
Bind("WAddress1") %>'></asp:Label><br />
<asp:Label ID="WCityLabel" runat="server" Text='<%# Bind("WCity")
%>'></asp:Label><br />
<asp:Label ID="WPhoneTextLabel" runat="server" Text="Phone:
"></asp:Label><asp:Label ID="WPhoneLabel" runat="server" Text='<%#
Bind("WPhone") %>'></asp:Label>
</ItemTemplate>
The problem is that if a column is blank the <br/> is still appended so the
cell is taller then it needs to be and I have less space to display more
rows. And in this data there are a lot of rows one or more blank columns.
There is one solution for condition like this use this tag to check condition
<%#Eval("FieldName")==DBNull.Value? "" : "<br/>" %>
I have one field in DB that have name of pdf file and i have to show download link if there is data in this field, here is the solution
<a href='Book_PDF/<%# Eval("Pdf")%>.pdf' style="text-decoration:none">
<%#Eval("Pdf") == DBNull.Value ? "" : "<img alt='' src='images/adobe-pdf.png' style='width: 25px;height: 30px' />" %>
</a>
Comments
Post a Comment