Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone, I have an application that logs a record history of changes made to a call similar to that in a helpdesk system. I've this gridview:
ASP.NET
<ContentTemplate>
                                    <table width="100%">
                                        <tr valign="top">
                                            <td align="center">
                                                <asp:GridView id="gvCallHistory" runat="server" ForeColor="#333333" BorderColor="Black" HorizontalAlign="Left" PageSize="20" GridLines="Horizontal" Width="100%" Font-Size="X-Small" Font-Names="Verdana" CellPadding="4" EmptyDataText="No History Found" AutoGenerateColumns="False">
                                                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" Font-Size="Small" VerticalAlign="Top" HorizontalAlign="Left"  />
                                                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Left"  />
                                                    <EditRowStyle BackColor="#FFFF80"  />
                                                    <SelectedRowStyle Font-Bold="False"  />
                                                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Left"  />
                                                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" HorizontalAlign="Left"  />
                                                    <AlternatingRowStyle BackColor="White" ForeColor="#284775"  />
                                                    <PagerSettings Mode="NumericFirstLast"  />
                                                    <EmptyDataRowStyle CssClass="Label_Small_Bold" ForeColor="#C00000" HorizontalAlign="Center"  />
                                                    <Columns>
                                                        <asp:BoundField DataField="AuthNumber" HeaderText="Auth Number" ReadOnly="True" Visible="False">
                                                            <HeaderStyle HorizontalAlign="Left" />
                                                        </asp:BoundField>
                                                        <asp:BoundField DataField="HistoryID" ReadOnly="True" >
                                                            <HeaderStyle HorizontalAlign="Left" />
                                                        </asp:BoundField>
                                                        <asp:BoundField DataField="NoteDate" DataFormatString="{0:d}" HeaderText="Date" ReadOnly="True" >
                                                            <HeaderStyle HorizontalAlign="Left" />
                                                        </asp:BoundField>
                                                        <asp:BoundField DataField="Note" HeaderText="Description" ReadOnly="True" >
                                                            <HeaderStyle HorizontalAlign="Left" />
                                                        </asp:BoundField>
                                                        <asp:BoundField DataField="Username" HeaderText="User" ReadOnly="True" >
                                                            <HeaderStyle HorizontalAlign="Left" />
                                                        </asp:BoundField>
                                                        <asp:TemplateField  ShowHeader="False">
                                                        <ItemTemplate>
                                                                <asp:Button ID="btnViewEmail" runat="server" CommandName="Select" Text="View" />
                                                            </ItemTemplate>
                                                            <ControlStyle CssClass="Label_Small" />
                                                        </asp:TemplateField>
                                                    </Columns>
                                                </asp:GridView>
                                            </td>
                                        </tr>
                                    </table>
                                </ContentTemplate>

what i would like to do is just display the btnViewEmail only on rows where there is a record beginning: "Email Sent: Subject - ..." in the Description column? there will be text where I have placed ... but this will not be consistent with each historical record.

Question 2: what is the best method for me to display the sent email to the user once the button is clicked - at present I am logging the email details into the DB table but there maybe attachments sent as part of the original email?
Posted

1 solution

Solution to Question 1:
C#
protected void gvCallHistory_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string strNotes = DataBinder.Eval(e.Row.DataItem, "Note").ToString();
                string strDescription = strNotes.Substring(0, 10);
                
                if (strDescription == "Email Sent") ((Button)e.Row.FindControl("btnViewEmail")).Visible = true;                
                else ((Button)e.Row.FindControl("btnViewEmail")).Visible = false;
            }
        }
 
Share this answer
 
Comments
AshishChaudha 13-Aug-12 11:45am    
my +5!...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900