Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 771
  • Last Modified:

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("ATTACHMENT_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><%#Eval("DEALS_NAME")%></Strong></TD></TR>
                                                <TR>
                                                <TD width="80%"><p class="InputDisplay"><%#Eval("DEALS_DETAILS")%></p></TD>
                                                <TD width="20%">
<%# IIf(Eval("ATTACHMENT_FILE") = "",<%#Eval("FILE_NAME_URL")%>, <img src="Assets/<%#Eval("ATTACHMENT_FILE")%>) %>
"/></TD>
                                                </TR>                                                <TR><TD width="100%" colspan="2"><TABLE width="100%" class="InputDisplay"><TR><TD  align="left" width="20%">Vendor:&nbsp;<i><%#Eval("VENDOR_NAME")%></i></TD><TD align="left"  width="20%">List Price:&nbsp;<i>US$<%#Eval("LIST_PRICE")%></i></TD><TD  align="left" width="20%">Category:&nbsp;<i><%#Eval("DEAL_CATEGORY")%></i></TD><TD  align="left" width="20%"><a target="_blank" style="TEXT-DECORATION: none" href="NotifyCredits.aspx?ID=<%#Eval("ID")%>">Notify Friends & Earn Credits</a></TD><TD align="left" width="20%"><a target="_blank" style="TEXT-DECORATION: none" href="1-ClickAccess.aspx?id=<%#Eval("ID")%>">1-Click Access</a>&nbsp;&nbsp;&nbsp;<!--<a style="TEXT-DECORATION: none" href="DealsPreview.aspx?ID=<%# Eval("ID") %>&Option=2">more details</a>&nbsp;--></TD></TR></TABLE></TD></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&amp;gt;" PreviousPageText="&amp;lt;Prev Deals" Mode="NextPrevious" />
                                </asp:GridView>
0
TECH_NET
Asked:
TECH_NET
1 Solution
 
Sammy AgeilCommented:
You should do this in the gridview's RowDataBound event in code behind not in the aspx file
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
0
 
TECH_NETAuthor Commented:
please close the ticket.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now