2016-11-14 5 views
0

サイトの新しいレコーダーに関する質問は、特定のコースに登録したいと思っています。登録リンクを介してデータを入力してください.. OK ..そして電子メールにデータを送信しますコードは正しく動作します..しかし、私の質問はここに..どのように私は電子メールのためにこのセッションデータを持って来るのですか?次のように コース名 日...VBコードを使用してASP.Netの電子メールで<%#Eval( "item")%>を送信してください

コード:

Schedule.aspx:私のようにメールで知らせるために、会員登録を新規ユーザのための(「アイテム」)評価を送ることができますどのように

<asp:Repeater ID="RepeaterCourse" runat="server"> 
    <ItemTemplate> 
     <div style="width: 30%;"> 
      <asp:Label ID="LabelEnglishName" runat="server" CssClass="LabelReg"><%# Eval("EnglishName")%></asp:Label> 
     </div> 
     <label id="CityCountry" style="float: left; margin-left: -15px; margin-right: 15px; color: maroon; font-size: 13px; text-align: center; width: 20%; margin-top: 20px;"><%# Eval("CityCountry")%></label> 
     <label id="StartCourse" style="float: left; color: maroon; font-size: 13px; width: 20%; margin-left: 15px; margin-right: -13px; margin-top: 20px;"><%# Eval("StartCourse", "{0:MMM dd, yyyy}")%></label> 
     <label id="EndCourse" style="float: left; color: maroon; font-size: 13px; width: 20%; margin-top: 20px;"><%# Eval("EndCourse", "{0:MMM dd, yyyy}")%></label> 
     <label id="Days" style="float: left; width: 20%; margin-top: 20px;"><%# Eval("Days")%></label> 
     </div> 
    </ItemTemplate> 
</asp:Repeater> 

VB.Netコード

Public Function FindCourse() As DataTable 
 
     GetConnection() 
 
     Dim SQL As String = "SELECT DISTINCT ScheduleNew.ScheduleID, ScheduleNew.CourseID , ScheduleNew.CityID, ScheduleNew.StartCourse, ScheduleNew.EndCourse, ScheduleNew.Days, ScheduleNew.CountryID, ScheduleNew.CategoryID, ScheduleNew.FieldID , ScheduleNew.Note, ScheduleNew.MonthsID , CoursesNew.CourseLogo , CoursesNew.EnglishName , (City.CityName +', ' +Country.CountryName) AS CityCountry FROM ScheduleNew ,CoursesNew , Country , City , Months Where Country.CountryID=City.CountryID AND City.CityID=ScheduleNew.CityID AND CoursesNew.CourseID=ScheduleNew.CourseID AND Months.MonthsID = ScheduleNew.MonthsID " 
 
    
 
     Dim dt As New DataTable 
 
     Dim da As New SqlDataAdapter(SQL, Conn) 
 
    
 
     If CountryID <> 0 Then 
 
      da.SelectCommand.CommandText = " AND City.CountryID = @CountryID" 
 
      da.SelectCommand.Parameters.Add("@CountryID", SqlDbType.Int).Value = CountryID 
 
     End If 
 
    
 
     If ScheduleID <> 0 Then 
 
      da.SelectCommand.CommandText &= "And ScheduleNew.ScheduleID [email protected]" 
 
      da.SelectCommand.Parameters.Add("@ScheduleID", SqlDbType.Int).Value = ScheduleID 
 
     End If 
 
    
 
     If CourseID <> 0 Then 
 
      da.SelectCommand.CommandText &= "And ScheduleNew.CourseID [email protected]" 
 
      da.SelectCommand.Parameters.Add("@CourseID", SqlDbType.Int).Value = CourseID 
 
     End If 
 
    
 
     If CityID <> 0 Then 
 
      da.SelectCommand.CommandText &= " And ScheduleNew.CityID [email protected]" 
 
      da.SelectCommand.Parameters.Add("@CityID", SqlDbType.Int).Value = CityID 
 
     End If 
 
    
 
     If StartCourse <> "" Then 
 
      da.SelectCommand.CommandText &= " And ScheduleNew.StartCourse Like @StartCourse " 
 
      da.SelectCommand.Parameters.Add("@StartCourse", SqlDbType.DateTime).Value = "%" & StartCourse & "%" 
 
     End If 
 
    
 
     If EndCourse <> "" Then 
 
      da.SelectCommand.CommandText &= " And ScheduleNew.EndCourse Like @EndCourse" 
 
      da.SelectCommand.Parameters.Add("@EndCourse", SqlDbType.DateTime).Value = "%" & EndCourse & "%" 
 
     End If 
 
    
 
     If MonthsID <> 0 Then 
 
      da.SelectCommand.CommandText &= " And [email protected]" 
 
      da.SelectCommand.Parameters.Add("@MonthsID", SqlDbType.Int).Value = MonthsID 
 
     End If 
 
    
 
     If CategoryID <> 0 Then 
 
      da.SelectCommand.CommandText &= " And [email protected]" 
 
      da.SelectCommand.Parameters.Add("@CategoryID", SqlDbType.Int).Value = CategoryID 
 
     End If 
 
    
 
     If FieldID <> 0 Then 
 
      da.SelectCommand.CommandText &= " And [email protected]" 
 
      da.SelectCommand.Parameters.Add("@FieldID", SqlDbType.Int).Value = FieldID 
 
     End If 
 
    
 
     If Days <> 0 Then 
 
      da.SelectCommand.CommandText &= " And [email protected]" 
 
      da.SelectCommand.Parameters.Add("@Days", SqlDbType.int).Value = Days 
 
     End If 
 
    
 
    
 
     da.SelectCommand.CommandText &= " order by StartCourse asc" 
 
    
 
     Try 
 
      da.Fill(dt) 
 
     Catch ex As Exception 
 
      'Error 
 
     Finally 
 
      Conn.Close() 
 
     End Try 
 
     Return dt 
 
    End Function

ページ枚の

画像:

http://www.directupload.net/file/d/4539/spzkruw8_png.htm

http://www.directupload.net/file/d/4539/dvndgvpy_png.htm

答えて

0

あなたはそのためOnItemCommandイベントを使用することができます。イベントをリピータに追加します。

<asp:Repeater ID="RepeaterCourse" runat="server" OnItemCommand="RepeaterCourse_ItemCommand"> 

そしてCommandNameCommandArgumentとリピータのテンプレートにボタンを追加します。

<asp:Button ID="Button1" runat="server" Text="Button" CommandName="emailCourse" CommandArgument='<%# Eval("item") %>' /> 

コードビハインドです。

Protected Sub RepeaterCourse_ItemCommand(ByVal source As Object, ByVal e As RepeaterCommandEventArgs) 
    'check if the commandname is the correct one (multiple buttons can use the same itemcommand) 
    If (e.CommandName = "emailCourse") Then 
     'get the value of the commandargument 
     Dim itemID As String = e.CommandArgument.ToString 

     'send the email here 
    End If   
End Sub 
+0

こんにちはVDWWD、 OK、私はこのコードを実行します。 非常にありがとうございました。 –

関連する問題