Hi all,
For this I am using ASP.NET 4.5, C#, and Entity Framework to SQL.
I have some sections of my site where users can make multiple entries and can optionally upload attachments. There is a page where the user can see a gridview that acts as an overview of the entires. I have been asked to display a column with a paperclip icon if an attachment exists.
The way the database is structured, the table that holds the entries has columns like this:
id, schoolName, dateStarted, dateEnded, attachmentId
The attachments are in another table. For this table the attachmentId will hold an Int32 or be NULL (no attachment). My current query looks like basically like this:
var query = context.applications.Where(c => c.id == applicationPrimaryKey);
var results = result.educationUniversities.ToList();
gdvEducationUniversity.DataSource = results;
gdvEducationUniversity.DataBind();
Gridview looks like this:
<asp:GridView
ID="gdvWorkMentor"
runat="server"
AutoGenerateColumns="False"
DataKeyNames="id"
<Columns>
<asp:BoundField AccessibleHeaderText="Trainee Name" DataField="traineeName" HeaderText="Trainee Name" HtmlEncode="False" />
<asp:BoundField AccessibleHeaderText="Employer/Agency" DataField="employerAgency" HeaderText="Employer/Agency" HtmlEncode="False" />
<asp:BoundField AccessibleHeaderText="Start Date" DataField="dateStart" HeaderText="Start Date" DataFormatString="{0:MM/dd/yyyy}" />
<asp:BoundField AccessibleHeaderText="End Date" DataField="dateEnd" HeaderText="End Date" DataFormatString="{0:MM/dd/yyyy}" />
<asp:ButtonField AccessibleHeaderText="View/Edit" CommandName="view" HeaderText="View/Edit" Text="View/Edit" />
<asp:ButtonField AccessibleHeaderText="Delete" CommandName="deleteCustom" HeaderText="Delete" Text="Delete" />
</Columns>
</asp:GridView>
I somehow need to create a condition where an image of a paperclip is shown if the attachmentId value is not Null. Optionally I imagine the query could be re-written to return a true/false value based on if the attachmentId value is null though I'm not certain how to do this. Need a nudge in the right direction on this one.
Thanks!