我們希望在更新時發送電子郵件。如何發送autoGenerateEditButton設置爲True的電子郵件?
如何在gridview的autogenerateEditButton設置爲true時執行此操作?
下面是一個例子:
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False" DataKeyNames="ID" AllowPaging="True"
OnRowDataBound="gvRowDataBound" **onRowUpdated="btnSendEmail_Click"** AutoGenerateEditButton="True">
<Columns>
<asp:BoundField DataField="date_stamp" HeaderText="Entry Date" ReadOnly = "true"
SortExpression="date_stamp" />
</Columns>
</asp:GridView>
我的電子郵件代碼是代碼隱藏叫sub btnSendEmail_Click()
。
Protected Sub btnSendEmail_Click(ByVal sender As Object, ByVal e As GridViewUpdatedEventArgs)
Dim cnn As SqlConnection
'Dim param As SqlParameter
Dim cmd As SqlCommand
Dim sqlStr As String = ""
Dim sqlStrD As String = ""
Dim connStr As String = ConfigurationManager.ConnectionStrings("Database_DBConnectionString").ConnectionString
more - not posted
more - not posted
謝謝zeroef;你很棒。一個問題。我發現你在SendEmail裏有一個參數 - SendEmail(row.Cells(0).Text)。這是否意味着我需要添加一個參數到我的btnSendEmail_Click子?如果是的話,我應該怎麼稱呼它? – Kenny
@Kenny - 已更新的答案 – zeroef