Hey,
I am trying to figure something out, on this page:
http://kidsunlimited.co.uk/test.aspx
I have the following code:
<asp:GridView ID="GridView1" runat="server" CellPadding="10"
ForeColor="#333333" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
PageSize="30" cssclass="GridViewStyle"
onrowdatabound="GridView1_RowDataBound">
<FooterStyle CssClass="GridViewFooterStyle" />
<RowStyle CssClass="GridViewRowStyle" />
<SelectedRowStyle CssClass="GridViewSelectedRowStyle" />
<PagerStyle CssClass="GridViewPagerStyle" />
<AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" />
<HeaderStyle CssClass="GridViewHeaderStyle" />
<Columns>
<asp:BoundField DataField="application_id" HeaderText="application_id" InsertVisible="False" ReadOnly="True" SortExpression="application_id" Visible="False" />
<asp:BoundField DataField="fname" HeaderText="Forename" SortExpression="fname" />
<asp:BoundField DataField="sname" HeaderText="Surname" SortExpression="sname" />
<asp:BoundField DataField="cv" HeaderText="CV" SortExpression="cv" ItemStyle-CssClass="tdclass"/>
<asp:BoundField DataField="status" HeaderText="Status" SortExpression="status" />
<asp:BoundField DataField="date_addedd" HeaderText="Date" SortExpression="date_addedd" DataFormatString="{0:U}" HtmlEncode="false"/>
<asp:TemplateField HeaderText="Forward">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:CheckBox ID="ApplSelector" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" Text='View application'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:HyperLink ID="HyperLink2" runat="server" Text='Edit status'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center"/>
<ItemTemplate>
<asp:HyperLink ID="HyperLink3" runat="server" Text='Delete'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="CheckAll" runat="server" Text="Check All" onclick="CheckAll_Click" />
<asp:Button ID="UncheckAll" runat="server" Text="Uncheck All" onclick="UncheckAll_Click" />
<asp:Button ID="ForwardCVApplications" runat="server" Text="Forward Applications" onclick="ForwardCVApplications_Click" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SQL2008_673062_kidsConnectionString %>"
SelectCommand="SELECT [application_id], [fname], [sname], [cv], [status], [date_addedd] FROM [tbl_apprenticeship_applications]">
</asp:SqlDataSource>
And what i want to do is on “ForwardCVApplications_Click” i want to attach all the [cv] documents which are located on the server to an email. What i want is when the button is clicked it opens an email software such as Outlook and has the [cv] (whiever are selected via the checkbox) to be attached to the email.
The other bits of the email such as To, and Subject can be filled in manually. I currently have this in the .cs file:
private void ToggleCheckState(bool checkState)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox cb = (CheckBox)row.FindControl("ApplSelector");
if (cb != null) cb.Checked = checkState;
}
}
protected void ForwardCVApplications_Click(object sender, EventArgs e)
{
}
protected void CheckAll_Click(object sender, EventArgs e)
{
ToggleCheckState(true);
}
protected void UncheckAll_Click(object sender, EventArgs e)
{
ToggleCheckState(false);
}
Any ideas how i can accomplish this on the Button click?
Thanks