TECH_NET
asked on
Conditional statement in ASP GRID
What is wrong with the statement to show a Grid Column. I am checking the value of ATTACHMENT_FILE column from database, and if this value is NULL then i want the column to display the value in column FILE_NAME_URL from the database.
<%# IIf(Eval("ATTACHMENT_FILE" ) = "",<%#Eval("FILE_NAME_URL" )%>, <img src="Assets/<%#Eval("ATTAC HMENT_FILE ")%>) %>
<asp:GridView ID="dgGrid" runat="server" AutoGenerateColumns="False " Width=100% CellPadding="4" ForeColor="#333333" DataKeyNames="ID" PageSize="25" AllowPaging="True" >
<Columns>
<asp:TemplateField HeaderText=" ">
<ItemTemplate>
<TABLE width="100%">
<TR><TD colspan="2" valign="top"><Strong><%#Ev al("DEALS_ NAME")%></ Strong></T D></TR>
<TR>
<TD width="80%"><p class="InputDisplay"><%#Ev al("DEALS_ DETAILS")% ></p></TD>
<TD width="20%">
<%# IIf(Eval("ATTACHMENT_FILE" ) = "",<%#Eval("FILE_NAME_URL" )%>, <img src="Assets/<%#Eval("ATTAC HMENT_FILE ")%>) %>
"/></TD>
</TR> <TR><TD width="100%" colspan="2"><TABLE width="100%" class="InputDisplay"><TR>< TD align="left" width="20%">Vendor: < i><%#Eval( "VENDOR_NA ME")%></i> </TD><TD align="left" width="20%">List Price: <i>US$<%#Eval( "LIST_PRIC E")%></i>< /TD><TD align="left" width="20%">Category:  ;<i><%#Eva l("DEAL_CA TEGORY")%> </i></TD>< TD align="left" width="20%"><a target="_blank" style="TEXT-DECORATION: none" href="NotifyCredits.aspx?I D=<%#Eval( "ID")%>">N otify Friends & Earn Credits</a></TD><TD align="left" width="20%"><a target="_blank" style="TEXT-DECORATION: none" href="1-ClickAccess.aspx?i d=<%#Eval( "ID")%>">1 -Click Access</a> &nbs p;<!--<a style="TEXT-DECORATION: none" href="DealsPreview.aspx?ID =<%# Eval("ID") %>&Option=2">more details</a> --></TD>< /TR></TABL E></TD></T R>
</TABLE>
</ItemTemplate>
<HeaderStyle CssClass="InputDisplay" HorizontalAlign="Left" VerticalAlign="Top" Width="15%" />
</asp:TemplateField>
</Columns>
<RowStyle Font-Names="Arial" Font-Size="Smaller" BackColor="#EFF3FB" />
<AlternatingRowStyle Font-Names="Arial" Font-Size="Smaller" BackColor="#F7F7FF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle cssclass="tableLabel" ForeColor="Black" HorizontalAlign="Left" />
<HeaderStyle cssclass="TableMain" Font-Bold="True" height=10px ForeColor="White" />
<PagerSettings NextPageText="Next Deals&gt;" PreviousPageText="&lt; Prev Deals" Mode="NextPrevious" />
</asp:GridView>
<%# IIf(Eval("ATTACHMENT_FILE"
<asp:GridView ID="dgGrid" runat="server" AutoGenerateColumns="False
<Columns>
<asp:TemplateField HeaderText=" ">
<ItemTemplate>
<TABLE width="100%">
<TR><TD colspan="2" valign="top"><Strong><%#Ev
<TR>
<TD width="80%"><p class="InputDisplay"><%#Ev
<TD width="20%">
<%# IIf(Eval("ATTACHMENT_FILE"
"/></TD>
</TR> <TR><TD width="100%" colspan="2"><TABLE width="100%" class="InputDisplay"><TR><
</TABLE>
</ItemTemplate>
<HeaderStyle CssClass="InputDisplay" HorizontalAlign="Left" VerticalAlign="Top" Width="15%" />
</asp:TemplateField>
</Columns>
<RowStyle Font-Names="Arial" Font-Size="Smaller" BackColor="#EFF3FB" />
<AlternatingRowStyle Font-Names="Arial" Font-Size="Smaller" BackColor="#F7F7FF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle cssclass="tableLabel" ForeColor="Black" HorizontalAlign="Left" />
<HeaderStyle cssclass="TableMain" Font-Bold="True" height=10px ForeColor="White" />
<PagerSettings NextPageText="Next Deals&gt;" PreviousPageText="&lt;
</asp:GridView>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
some examples on how to use this event
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx
http://www.asp.net/learn/data-access/tutorial-11-vb.aspx
Good luck