I want to send in the email, the content of formview control

Y

YMPN

Hi Everyone,

I'm deen from Riyadh.

Please do help me with some problem i have. I have this formview
control setup to recieved inputs from user (textbox, dropdownlist,
others).

After inserting, I want to send the data via email, the problem is how
do I do that?

Simple form.request dont work, somebody told me to use findcontrol,
please explain.

I am new to asp.net but i quiet like it.

Thank you very much.

Deen
 
Y

YMPN

Thank you very much Nat,

But you see i have been through that site a thousand times. In that
example in 4guysfromrolla, they were using simple form But what I have
is Formview control and I dont know how to use findcontrol to add the
data inputted in the email that i will be sending.

With simple form easy but formview im getting blank values in the sent
email..

eg : findcontrol.formview.textbox1 and assign it into a value..


thanks everyone..
 
B

bpd

Show us the code.
YMPN said:
Thank you very much Nat,

But you see i have been through that site a thousand times. In that
example in 4guysfromrolla, they were using simple form But what I have
is Formview control and I dont know how to use findcontrol to add the
data inputted in the email that i will be sending.

With simple form easy but formview im getting blank values in the sent
email..

eg : findcontrol.formview.textbox1 and assign it into a value..


thanks everyone..
 
Y

YMPN

My issue I think is simple but since i'm coming from a CFM background I
have some difficulty. But ASP.Net has given me new excitement in my web
development life..


Here is the formview where the data is collected.....

-----------------------------------------------------------

<asp:FormView ID="FormView1" runat="server"
DataSourceID="DataSourceForm" DefaultMode="Insert"
Width="100%">
<InsertItemTemplate>
<table>
<tr>
<td rowspan="2" style="width: 350px">
</td>
<td colspan="2" rowspan="2">
<strong><span style="color: #56b63b"><span
style="color: #0000ff"></span>Please Enter
Required Information<span style="color:
blue"> </span></span></strong>
</td>
</tr>
<%-- user name set visible = false ??? --%>
<tr>
<td style="width: 400px; height: 33px;">
<asp:DropDownList ID="UserName" runat="server"
DataSourceID="SqlDataSource6" DataTextField="UserName"
DataValueField="UserName"
SelectedValue='<%# Bind("UserName") %>' Visible="False"
AutoPostBack="True">
</asp:DropDownList><asp:SqlDataSource
ID="SqlDataSource6" runat="server" ConnectionString="<%$
ConnectionStrings:RoomReservationConnectionString %>"
SelectCommand="SELECT [Fullname], [Id],
[UserName] FROM [UserInfo] WHERE ([UserName] = @UserName)">
<SelectParameters>
<asp:QueryStringParameter
DefaultValue="1" Name="UserName" QueryStringField="UserName"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
</tr>
<tr>
<td style="width: 350px; height: 27px">
</td>
<td style="width: 800px; height: 27px">
Type of Reservation</td>
<td style="width: 400px; height: 27px">
<br />
<asp:DropDownList ID="DropDownList"
runat="server" SelectedValue='<%# Bind("Reservation_cat") %>'
DataSourceID="SqlDataSource1"
DataTextField="category" DataValueField="category"
AppendDataBoundItems="True"
AutoPostBack="True" OnTextChanged="DropDownList_TextChanged">
</asp:DropDownList><asp:SqlDataSource
ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:RoomReservationConnectionString %>"
SelectCommand="SELECT * FROM
[reservation_category] ORDER BY [cat_id] ASC"></asp:SqlDataSource>
<br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px; height: 27px;">
</td>
<td style="width: 800px; height: 27px;">
Date From</td>
<td style="width: 400px; height: 27px;">
<ew:CalendarPopup ID="CalendarPopup1"
runat="server" PostedDate="" SelectedDate='<%# Bind("Date_From") %>'
ImageUrl="~/images/calendar4.jpg"
ControlDisplay="TextBoxImage" UpperBoundDate="12/31/9999 23:59:59"
Culture="(Default)" Text="Select Date
From">
<ButtonStyle Font-Names="verdana"
Font-Size="8pt" BackColor="#DEE37F" />
</ew:CalendarPopup>
<br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px">
</td>
<td style="width: 800px">
Date To</td>
<td style="width: 400px">
<ew:CalendarPopup ID="CalendarPopup2"
ImageUrl="~/images/calendar4.jpg" ControlDisplay="TextBoxImage"
runat="server" SelectedDate='<%#
Bind("Date_To") %>' Text="Select Date To">
<ButtonStyle BackColor="#DEE37F"
Font-Names="verdana" Font-Size="8pt" />
</ew:CalendarPopup>
<br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px">
</td>
<td style="width: 800px">
Time From</td>
<td style="width: 400px">
<ew:TimePicker ID="tpDemo2" runat="server"
ImageUrl="~/images/calendar3.jpg" NumberOfColumns="3"
LowerBoundTime="11/25/3506 07:00:00"
UpperBoundTime="11/25/3506 23:00:00" ControlDisplay="TextBoxImage"
PopupLocation="Bottom" PopupWidth="170px"
PopupHeight="178px" SelectedValue='<%# Bind("Time_From", "{0:t}") %>'
PostedTime="7:00 PM"
SelectedTime="11/25/3506 19:00:28" Text="Select Time Start">
<SelectedTimeStyle BackColor="Khaki"
ForeColor="Black" />
<TimeStyle BackColor="SteelBlue"
ForeColor="White" />
<ButtonStyle BackColor="#DEE37F"
Font-Names="verdana" Font-Size="8pt" />
</ew:TimePicker>
<br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px">
</td>
<td style="width: 800px">
Time To</td>
<td style="width: 400px">
<ew:TimePicker ID="TimePicker1" runat="server"
ImageUrl="~/images/calendar3.jpg"
ControlDisplay="TextBoxImage"
NumberOfColumns="3" LowerBoundTime="11/25/3506 07:00:00"
UpperBoundTime="11/25/3506 23:00:00"
PopupLocation="Bottom" PopupWidth="170px"
PopupHeight="178px" SelectedValue='<%#
Bind("Time_To", "{0:t}") %>' PostedTime="7:00 PM"
SelectedTime="11/25/3506 19:00:28"
Text="Select Time Ends">
<SelectedTimeStyle BackColor="Khaki"
ForeColor="Black" />
<TimeStyle BackColor="SteelBlue"
ForeColor="White" />
<ButtonStyle BackColor="#DEE37F"
Font-Names="verdana" Font-Size="8pt" />
</ew:TimePicker>
<br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px">
</td>
<td style="width: 800px" valign="top">
Activity</td>
<td style="width: 400px">
<span style="color: red"><strong>Events or
Reasons for this Reservation</strong></span><br />
<asp:TextBox ID="ReasonTextBox" runat="server"
Text='<%# Bind("Reason") %>' CausesValidation="True"
Height="50px" TextMode="MultiLine"
Width="250px"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server"
ControlToValidate="ReasonTextBox"
ErrorMessage="This Field is
Required"></asp:RequiredFieldValidator>
<br />
</td>
</tr>
<%-- Start of room--%>
<tr>
<td style="width: 350px" valign="top">
</td>
<td style="width: 800px" valign="top">
<br />
Room No.</td>
<td style="width: 400px" valign="top">
<br />
<asp:DropDownList ID="RoomNo" runat="server"
DataSourceID="SqlDataSource3" DataTextField="RoomNo"
AppendDataBoundItems="true"
DataValueField="RoomNo" SelectedValue='<%# Bind("RoomNo") %>'>
<asp:ListItem Selected="True">Pls. Select
Your Room No.</asp:ListItem>
</asp:DropDownList><br />
<br />
</td>
</tr>
<tr>
<td style="width: 350px">
</td>
<td style="width: 800px" valign="top">
<br />
Equipment</td>
<td style="width: 400px">
<asp:DropDownList ID="DropDownList1"
runat="server" DataSourceID="SqlDataSource5"
DataTextField="EquipmentName"
DataValueField="EquipmentName" SelectedValue='<%# Bind("Equipments")
%>'
AppendDataBoundItems="true">
<asp:ListItem Selected="True">Pls. Select
Your Equipment</asp:ListItem>
</asp:DropDownList><br />
<br />
</td>
</tr>
<%-- extra location for equipment reservation--%>
<tr id="locatione" runat="server" visible="false">
<td style="width: 350px">
</td>
<td style="width: 800px" valign="top">
<br />
Location for Equipment</td>
<td style="width: 400px">
<br />
<asp:TextBox ID="TextBox1" runat="server"
CausesValidation="True" Text='<%# Bind("OtherRoomNo") %>'
Width="250px"></asp:TextBox><br />
<br />
</td>
</tr>
<%-- extra location for equipment reservation--%>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:RoomReservationConnectionString
%>"
SelectCommand="SELECT * FROM
[RoomInfo]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource5" runat="server"
ConnectionString="<%$ ConnectionStrings:RoomReservationConnectionString
%>"
SelectCommand="SELECT * FROM
[Equipments]"></asp:SqlDataSource>
<%--insert/cancel button--%>
<tr>
<td style="width: 350px">
</td>
<td colspan="3" valign="top">
<asp:ImageButton ID="InsertButton"
runat="server" ForeColor="#56b63b" CommandName="Insert"
ImageUrl="~/images/insert_all.jpg"
OnClientClick="return confirm('Are you certain that you want to reserve
this details?');">
</asp:ImageButton>
<asp:ImageButton ID="InsertCancelButton"
runat="server" ForeColor="#56b63b" CausesValidation="False"
CommandName="Cancel"
ImageUrl="~/images/cancel_all.jpg" OnClientClick="return confirm('Are
you certain that you want to cancel this details?');">
</asp:ImageButton>
</td>
</tr>
<%--insert/cancel button--%>
</table>
</InsertItemTemplate>
</asp:FormView>


And here the code that sends the email....




Protected Sub FormView1_ItemInserted(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.FormViewInsertedEventArgs) Handles
FormView1.ItemInserted


' ''***** Send Email ******************
''Find controls value on page and send to email ??? -
HOW??????

Dim strBody As String
Dim strMailTo As String

strMailTo = Session("UserName").ToString & "@kfmc.med.sa"
strBody = "Dear " & Session("FullName").ToString &
"<br><br>Thank you for using Room & Equipment Reservation System, Your
reservation has been received <br><br>"
' strBody = strBody & "<brV>To view the details of your
reservation online, <a
href=http://rkweb01:8779/viewmyreserved_admin.aspx> Click Here!</a>"
strBody = strBody & "<br><br>Best Regards, <br>"
strBody = strBody & "<br>Administrator <br>"
strBody = strBody & "<br><br>Ext: 2174, 2529"
strBody = strBody & "<br><br>Ext:
RoomReservation@(kfmc.med.sa)"

Dim msg As System.Net.Mail.MailMessage = New
System.Net.Mail.MailMessage
Dim strFrom As System.Net.Mail.MailAddress = New
System.Net.Mail.MailAddress("xxxxxx")
msg.Subject = "New Room Reservation"
msg.To.Add(strMailTo)
msg.CC.Add("xxxxxx")
msg.From = strFrom
msg.IsBodyHtml = True
msg.Body = strBody

Try
Dim smtp As System.Net.Mail.SmtpClient = New
System.Net.Mail.SmtpClient
smtp.Host = "xxxxxxxx"
smtp.Send(msg)
'***** End of Sending Email ***************
' strRN = ""
Response.Redirect("viewmyreserved_admin.aspx")
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top