Solved

Unable to send emails from ASP.NET page

Posted on 2009-05-11
72
773 Views
Last Modified: 2012-05-06
Hi,
I have a ASP.NET web page, when the user updates the form and then sends Email to the user (the complete content in the form). The problem is the user is not receiving any email's. There are no errors reported by ASP.net, the email address is valid. I am completely lost why it is not working.

Any help greatly appreciated.
Thanks in advance!
Here is the code 
 

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Text" %>

<%@ Import Namespace="System.Net.Mail" %>

<%@ Import Namespace="System.Web.Mail" %>

<%@ Import Namespace="System.Web.UI.WebControls" %>

<%@ Import Namespace="System.Web.UI.WebControls.WebParts" %>

<%@ Import Namespace="System.Data.SqlClient" %>
 

<asp:Content id="Content1" runat="server" contentplaceholderid="ContentPlaceHolder1">

	<script runat="server">

protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)

{

string problemID = (string)e.Values["ProblemID"];

string userName = (string)e.Values["UserName"];

string userEmail = (string)e.Values["UserEmail"];

string userLocation = (string)e.Values["UserLocation"];

string userPhone = (string)e.Values["UserPhone"];

string ocd = (string)e.Values["ocd"];

string DepartmentName = (string)e.Values["DepartmentName"];

string UserNH = (string)e.Values["UserNH"];

string UserSSN = (string)e.Values["UserSSN"];

string IsRepresentativeInvolved = (string)e.Values["IsRepresentativeInvolved"];

string RepresentativeSSN = (string)e.Values["RepresentativeSSN"];

string RepresentativeZipCode = (string)e.Values["RepresentativeZipCode"];

string OrganizationName = (string)e.Values["OrganizationName"];

string ClaimantName = (string)e.Values["ClaimantName"];

string IsProblemQuestion = (string)e.Values["IsProblemQuestion"];

string IsComment = (string)e.Values["IsComment"];

string ProblemTitle = (string)e.Values["ProblemTitle"];

string ProblemDescription = (string)e.Values["ProblemDescription"];

string Attachment = (string)e.Values["Attachment"];

string TeamMemberName = (string)e.Values["TeamMemberName"];

string solution = (string)e.Values["solution"];

string KnowledgeBaseNotes = (string)e.Values["KnowledgeBaseNotes"];
 

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();

message.From = new MailAddress("shruthi.andem@ssa.gov", "System E-mail");

message.To.Add(new MailAddress(userEmail, userName));

message.Subject = "Problem submission";

message.Body =

  "Name: " + userName + "\n" +

  "Email: " + userEmail + "\n" +

  "Location: " + userLocation + "\n" +

  "Phone: " + userPhone + "\n" +

   "DOC: " + ocd + "\n" +

  "ProblemTitle: " + ProblemTitle + "\n" +

  "solution: " + solution + "\n" +

  "KnowledgeBaseNotes: " + KnowledgeBaseNotes + "\n" +

  "ProblemID: " + problemID;

SmtpClient client = new SmtpClient();

client.Send(message);

}

</script>
 

		<p class="style1">

	<asp:SqlDataSource id="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:HelpDeskConnectionString %>" SelectCommand="SELECT TeamMemberName, TeamMemberID FROM TeamMembers WHERE TeamMemberID &gt; 0 ORDER BY TeamMemberName ASC">

	</asp:SqlDataSource>

	<span style="color: #800000"><strong>Choose A Team Member:</strong></span>

	<asp:DropDownList id="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="TeamMemberName" DataValueField="TeamMemberID">

	</asp:DropDownList>

	<asp:SqlDataSource id="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:HelpDeskConnectionString %>" SelectCommand="SELECT PS.ProblemStatusId, TM.TeamMemberName, PROB.problemTitle, DEPT.DepartmentName, PS.ProblemStatus 

FROM ProblemsUsersDeptsReps AS REPS 

    INNER JOIN  Departments AS DEPT  

ON REPS.DepartmentID = DEPT.DepartmentID 

INNER JOIN Problems AS PROB 

ON REPS.ProblemID = PROB.ProblemID 

INNER JOIN ProblemStatus AS PS

ON REPS.ProblemsUsersDeptsRepsID = PS.ProblemsUsersDeptsRepsID 

INNER JOIN TeamMembers AS TM 

ON PS.TeamMemberId = TM.TeamMemberId 

AND TM.TeamMemberId = @TeamMemberId

Where UPPER(ps.ProblemStatus) in ('OPEN', 'REOPEN')">

		<SelectParameters>

			<asp:controlparameter ControlID="DropDownList1" Name="TeamMemberId" PropertyName="SelectedValue" />

		</SelectParameters>

	</asp:SqlDataSource>

	</p>

	

            

                                  

	<asp:GridView id="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ProblemStatusId" DataSourceID="SqlDataSource2" ForeColor="#333333" GridLines="None" HorizontalAlign="Center">

		<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />

		<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />

		<Columns>

			<asp:commandfield ShowSelectButton="True">

			</asp:commandfield>

			<asp:boundfield DataField="ProblemStatusId" HeaderText="Problem Id" InsertVisible="False" ReadOnly="True" SortExpression="ProblemStatusId">

			</asp:boundfield>

			<asp:boundfield DataField="TeamMemberName" HeaderText="Team Member Name" SortExpression="TeamMemberName">

			</asp:boundfield>

			<asp:boundfield DataField="problemTitle" HeaderText="Subject" SortExpression="problemTitle">

			</asp:boundfield>

			<asp:boundfield DataField="DepartmentName" HeaderText="Title Name" SortExpression="DepartmentName">

			</asp:boundfield>

			<asp:boundfield DataField="ProblemStatus" HeaderText="Problem Status" SortExpression="ProblemStatus">

			</asp:boundfield>

		</Columns>

		<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />

		<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />

		<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />

		<AlternatingRowStyle BackColor="White" />

		<EmptyDataTemplate>

       	 No Problems are assigned at present. </EmptyDataTemplate>

	</asp:GridView>

	<br />

	<br />

		<div class="style1" style="text-align: left">

	<asp:DetailsView id="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="ProblemStatusId" DataSourceID="SqlDataSource3" ForeColor="Black" GridLines="None" Height="50px" Width="100%" AllowPaging="True" OnItemInserted="DetailsView1_ItemInserted">

		<FooterStyle BackColor="Tan" />

		<PagerStyle BackColor="PaleGoldenrod" ForeColor="#ACA899" HorizontalAlign="Center" />

		<Fields>

			<asp:boundfield DataField="ProblemStatusId" HeaderText="ProblemStatusId" ReadOnly="True" InsertVisible="False" SortExpression="ProblemStatusId">

			</asp:boundfield>

			<asp:boundfield DataField="UserName" HeaderText="UserName" ReadOnly="True" SortExpression="UserName">

			</asp:boundfield>

			<asp:boundfield DataField="UserEmail" HeaderText="UserEmail" ReadOnly="True" SortExpression="UserEmail">

			</asp:boundfield>

			<asp:boundfield DataField="UserLocation" HeaderText="UserLocation" ReadOnly="True" SortExpression="UserLocation">

			</asp:boundfield>

			<asp:boundfield DataField="UserPhone" HeaderText="UserPhone" ReadOnly="True" SortExpression="UserPhone">

			</asp:boundfield>

			<asp:boundfield DataField="ocd" HeaderText="ocd" ReadOnly="True" SortExpression="ocd">

			</asp:boundfield>

			<asp:boundfield DataField="DepartmentName" HeaderText="DepartmentName" ReadOnly="True" SortExpression="DepartmentName">

			</asp:boundfield>

			<asp:boundfield DataField="UserNH" HeaderText="UserNH" ReadOnly="True" SortExpression="UserNH">

			</asp:boundfield>

			<asp:boundfield DataField="UserSSN" HeaderText="UserSSN" ReadOnly="True" SortExpression="UserSSN">

			</asp:boundfield>

			<asp:checkboxfield DataField="IsRepresentativeInvolved" HeaderText="IsRepresentativeInvolved" ReadOnly="True" SortExpression="IsRepresentativeInvolved">

			</asp:checkboxfield>

			<asp:boundfield DataField="RepresentativeSSN" HeaderText="RepresentativeSSN" ReadOnly="True" SortExpression="RepresentativeSSN">

			</asp:boundfield>

			<asp:boundfield DataField="RepresentativeZipCode" HeaderText="RepresentativeZipCode" ReadOnly="True" SortExpression="RepresentativeZipCode">

			</asp:boundfield>

			<asp:boundfield DataField="OrganizationName" HeaderText="OrganizationName" ReadOnly="True" SortExpression="OrganizationName">

			</asp:boundfield>

			<asp:boundfield DataField="ClaimantName" HeaderText="ClaimantName" ReadOnly="True" SortExpression="ClaimantName">

			</asp:boundfield>

			<asp:checkboxfield DataField="IsProblemQuestion" HeaderText="IsProblemQuestion" ReadOnly="True" SortExpression="IsProblemQuestion">

			</asp:checkboxfield>

			<asp:checkboxfield DataField="IsComment" HeaderText="IsComment" ReadOnly="True" SortExpression="IsComment">

			</asp:checkboxfield>

			<asp:boundfield DataField="ProblemTitle" HeaderText="ProblemTitle" ReadOnly="True" SortExpression="ProblemTitle">

			</asp:boundfield>

			<asp:boundfield DataField="ProblemDescription" HeaderText="ProblemDescription" ReadOnly="True" SortExpression="ProblemDescription">

			</asp:boundfield>

			<asp:boundfield DataField="Attachment" HeaderText="Attachment" ReadOnly="True" SortExpression="Attachment">

			</asp:boundfield>

			<asp:boundfield DataField="TeamMemberName" HeaderText="TeamMemberName" ReadOnly="True" SortExpression="TeamMemberName">

			</asp:boundfield>

			<asp:boundfield DataField="solution" HeaderText="solution" SortExpression="solution">

			</asp:boundfield>

			<asp:boundfield DataField="KnowledgeBaseNotes" HeaderText="KnowledgeBaseNotes" SortExpression="KnowledgeBaseNotes">

			</asp:boundfield>

			<asp:commandfield ShowEditButton="True">

			</asp:commandfield>

					</Fields>

		<HeaderStyle BackColor="Tan" Font-Bold="True" />

		<EditRowStyle BackColor="PaleGoldenrod" ForeColor="Black" />

		<AlternatingRowStyle BackColor="PaleGoldenrod" />

	</asp:DetailsView>

		</div>

	<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:HelpDeskConnectionString %>" SelectCommand="GetInformationForProblemStatusIdforAdmin" SelectCommandType="StoredProcedure" UpdateCommand="InsertOrUpdateAndClosedPSandKB" UpdateCommandType="StoredProcedure">

		<SelectParameters>

			<asp:controlparameter ControlID="GridView1" Name="problemStatusId" PropertyName="SelectedValue" Type="Int32" />

		</SelectParameters>

		<UpdateParameters>

			<asp:parameter Name="KnowledgeBaseNotes" Type="String" />

			<asp:parameter Direction="InputOutput" Name="problem_solution_id" Type="Int32" />

			<asp:parameter Name="ProblemStatusID" Type="Int32" />

			<asp:parameter Name="Solution" Type="String" />

		</UpdateParameters>

	</asp:SqlDataSource>

Open in new window

0
Comment
Question by:csaexperts
  • 36
  • 31
  • 3
  • +2
72 Comments
 
LVL 3

Expert Comment

by:OblivionSY
ID: 24355501
I don't think you have specified a mail server to use. By default it will use the local virtual server

try creating a new SMTPClient(string host) (1st overload) to tell it which SMTP server to use.

You may then get authentication errors, depending how the SMTP server is set up. If this is the case, create a new credential object (System.Net.NetworkCredential) passing in the user and password

then set the credentials property of the SMTP Client = the new credentials

Hope that helps
0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24355508
Could it be that your exchange server is blocking your emails, treating them as SPAM?
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24355546
I don't see where you're actually setting the mailserver. Unless you specify it in this file OR in your local app web.config file you may have some unpredictable behavior.

Two questions:
1. Is this a shared hosting environment that you have no control over?
2. Is the SMTP server you're trying to use "localhost"? If not the code above definitely won't send a message.
0
 
LVL 15

Expert Comment

by:OMC2000
ID: 24355584
I don't see SMTP server settings in your code. You may need to setup at lest the following parameters necessary for SMTP connection:

smtpClient.Host = SmtpServer;
smtpClient.Port = SmtpPort;

smtpClient.Credentials = new NetworkCredential(SmtpUserName, SmtpUserPass);

or set message headers

message.Headers.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", SmtpAuthProtocol.ToString());
message.Headers.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", SmtpUserName);
message.Headers.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", SmtpUserPass);

0
 

Author Comment

by:csaexperts
ID: 24356038
Thanks for the reply to all
 azarc3,
I sepecified mailserver settings in web.config.
Reg<system.net>
  <mailSettings>
   <smtp>
    <network host="**********"
    port="25"/>
   </smtp>
  </mailSettings>
 </system.net>
Regarding your questions:
1. Is this a shared hosting environment that you have no control over? - No its not a Shared hosting Environment and I dont have any control over it.
2. Is the SMTP server you're trying to use "localhost"? If not the code above definitely won't send a message  - This SMTP server is not a "localhost". if this code doesnt work, then can I have the code which works. I am new to asp.net programming
 

0
 
LVL 11

Expert Comment

by:azarc3
ID: 24356175
csaexperts,

Let me clarify: your code *WOULD* work in certain situations, but not in most scenarios...

... for instance, if the SMTP server that the Web Server uses has no alias known to the Web Server as "localhost" then your code *probably* wouldn't work because there's no given that default SMTP server was set in the root level web.config file.

The code you've listed should work *IF* the SMTP server you've hidden above is an open relay and doesn't require a message send request to provide credentials. If it does require credentials then you'll want to update your network key to the following (which should get you going):


<system.net>

  <mailSettings>

    <smtp from="test@foo.com">

      <network host="{smtp server address}" port="25" userName="{email account's smtp user name}" password="{email account's smtp password}" defaultCredentials="true" />

    </smtp>

  </mailSettings>

</system.net>

Open in new window

0
 

Author Comment

by:csaexperts
ID: 24356345
azarc3,
After adding credentials , I tried to execute the page on the server, I am still having issues with it
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

 
 
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24356470
You need to update your web.config file to display the actual error. Do the following:

1. Update the system.web/compliation key and set the "debug" attribute to "true".

2. Update the system.web/customErrors key and set the "mode" attribute to "Off".

Examples are below.
<configuration>

  <system.web>

    ...

    <compilation debug="true">

    ...

    <customErrors mode="Off" />

    ...

  </system.web>

</configuration>

Open in new window

0
 

Author Comment

by:csaexperts
ID: 24356759
azarc3,
I already did that, I am still getting the same issue
 

<configuration>
 <!--  Database settings
          This section sets the connection for Database to the application    -->
 <connectionStrings>
  <add name="HelpDeskConnectionString" connectionString="Data Source=@@@;Initial Catalog=##k;Persist Security Info=True;User ID=###;Password=##3k" providerName="System.Data.SqlClient"/>
 </connectionStrings>
 <system.net>
  <mailSettings>
   <smtp>
    <network host="#####"
    port="25" defaultCredentials="true"/>
   </smtp>
  </mailSettings>
 </system.net>
 <system.web>
  <httpHandlers>
   <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
  </httpHandlers>
  <compilation debug="true">
  <customErrors mode="Off" />
   <buildProviders>
    <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
   </buildProviders>
   <assemblies>
   <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="Microsoft.ReportViewer.WinForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Web.RegularExpressions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation></system.web></configuration>
 
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24356791
Can you post the URL or attach the code so I can see the error?
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24356800
... uh, I suggest a temporary URL that will be changed once you get things squared away.  ;)
0
 
LVL 3

Expert Comment

by:OblivionSY
ID: 24356857
Make sure you use the correct case needs to be "Off"

have you tried putting the host detail into the code, so

client = New SmtpClient("mail.yourserver.com");

and the credentials there too?
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24356907
It sounds like trying to see the error on the server is getting to be an obstacle and may not actually be the problem... and that you probably need to run debug this on your local machine... is that possible? You don't have to change your connection strings... just hit F5 on if the code is open in Visual Studio.
0
 

Author Comment

by:csaexperts
ID: 24356966
azarc3,
Here is the complete code:


<%@ Page Language="C#" masterpagefile="../Master/Master.master" title="Email Response System" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.Web.Mail" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.WebControls.WebParts" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<asp:Content id="Content1" runat="server" contentplaceholderid="ContentPlaceHolder1">
 <script runat="server">
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
string problemID = (string)e.Values["ProblemID"];
string userName = (string)e.Values["UserName"];
string userEmail = (string)e.Values["UserEmail"];
string userLocation = (string)e.Values["UserLocation"];
string userPhone = (string)e.Values["UserPhone"];
string ocd = (string)e.Values["ocd"];
string DepartmentName = (string)e.Values["DepartmentName"];
string UserNH = (string)e.Values["UserNH"];
string UserSSN = (string)e.Values["UserSSN"];
string IsRepresentativeInvolved = (string)e.Values["IsRepresentativeInvolved"];
string RepresentativeSSN = (string)e.Values["RepresentativeSSN"];
string RepresentativeZipCode = (string)e.Values["RepresentativeZipCode"];
string OrganizationName = (string)e.Values["OrganizationName"];
string ClaimantName = (string)e.Values["ClaimantName"];
string IsProblemQuestion = (string)e.Values["IsProblemQuestion"];
string IsComment = (string)e.Values["IsComment"];
string ProblemTitle = (string)e.Values["ProblemTitle"];
string ProblemDescription = (string)e.Values["ProblemDescription"];
string Attachment = (string)e.Values["Attachment"];
string TeamMemberName = (string)e.Values["TeamMemberName"];
string solution = (string)e.Values["solution"];
string KnowledgeBaseNotes = (string)e.Values["KnowledgeBaseNotes"];
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.From = new MailAddress(sam@soc.com, "System E-mail");
message.To.Add(new MailAddress(userEmail, userName));
message.Subject = "Problem submission";
message.Body =
  "Name: " + userName + "\n" +
  "Email: " + userEmail + "\n" +
  "Location: " + userLocation + "\n" +
  "Phone: " + userPhone + "\n" +
   "DOC: " + ocd + "\n" +
  "ProblemTitle: " + ProblemTitle + "\n" +
  "solution: " + solution + "\n" +
  "KnowledgeBaseNotes: " + KnowledgeBaseNotes + "\n" +
  "ProblemID: " + problemID;
 
smtpClient.Host = "!!!";
smtpClient.Port = "25";
smtpClient.Credentials = new NetworkCredential(SmtpUserName, SmtpUserPass);
client.EnableSsl = true;
client.Send(message);
}
</script>
  <p class="style1">
 <asp:SqlDataSource id="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:HelpDeskConnectionString %>" SelectCommand="SELECT TeamMemberName, TeamMemberID FROM TeamMembers WHERE TeamMemberID > 0 ORDER BY TeamMemberName ASC">
 </asp:SqlDataSource>
 <span style="color: #800000"><strong>Choose A Team Member:</strong></span>
 <asp:DropDownList id="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="TeamMemberName" DataValueField="TeamMemberID">
 </asp:DropDownList>
 <asp:SqlDataSource id="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:HelpDeskConnectionString %>" SelectCommand="SELECT PS.ProblemStatusId, TM.TeamMemberName, PROB.problemTitle, DEPT.DepartmentName, PS.ProblemStatus
FROM ProblemsUsersDeptsReps AS REPS
    INNER JOIN  Departments AS DEPT  
ON REPS.DepartmentID = DEPT.DepartmentID
INNER JOIN Problems AS PROB
ON REPS.ProblemID = PROB.ProblemID
INNER JOIN ProblemStatus AS PS
ON REPS.ProblemsUsersDeptsRepsID = PS.ProblemsUsersDeptsRepsID
INNER JOIN TeamMembers AS TM
ON PS.TeamMemberId = TM.TeamMemberId
AND TM.TeamMemberId = @TeamMemberId
Where UPPER(ps.ProblemStatus) in ('OPEN', 'REOPEN')">
  <SelectParameters>
   <asp:controlparameter ControlID="DropDownList1" Name="TeamMemberId" PropertyName="SelectedValue" />
  </SelectParameters>
 </asp:SqlDataSource>
 </p>
 
           
                                 
 <asp:GridView id="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ProblemStatusId" DataSourceID="SqlDataSource2" ForeColor="#333333" GridLines="None" HorizontalAlign="Center">
  <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
  <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
  <Columns>
   <asp:commandfield ShowSelectButton="True">
   </asp:commandfield>
   <asp:boundfield DataField="ProblemStatusId" HeaderText="Problem Id" InsertVisible="False" ReadOnly="True" SortExpression="ProblemStatusId">
   </asp:boundfield>
   <asp:boundfield DataField="TeamMemberName" HeaderText="Team Member Name" SortExpression="TeamMemberName">
   </asp:boundfield>
   <asp:boundfield DataField="problemTitle" HeaderText="Subject" SortExpression="problemTitle">
   </asp:boundfield>
   <asp:boundfield DataField="DepartmentName" HeaderText="Title Name" SortExpression="DepartmentName">
   </asp:boundfield>
   <asp:boundfield DataField="ProblemStatus" HeaderText="Problem Status" SortExpression="ProblemStatus">
   </asp:boundfield>
  </Columns>
  <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
  <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
  <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
  <AlternatingRowStyle BackColor="White" />
  <EmptyDataTemplate>
         No Problems are assigned at present. </EmptyDataTemplate>
 </asp:GridView>
 <br />
 <br />
  <div class="style1" style="text-align: left">
 <asp:DetailsView id="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="ProblemStatusId" DataSourceID="SqlDataSource3" ForeColor="Black" GridLines="None" Height="50px" Width="100%" AllowPaging="True" OnItemInserted="DetailsView1_ItemInserted">
  <FooterStyle BackColor="Tan" />
  <PagerStyle BackColor="PaleGoldenrod" ForeColor="#ACA899" HorizontalAlign="Center" />
  <Fields>
   <asp:boundfield DataField="ProblemStatusId" HeaderText="ProblemStatusId" ReadOnly="True" InsertVisible="False" SortExpression="ProblemStatusId">
   </asp:boundfield>
   <asp:boundfield DataField="UserName" HeaderText="UserName" ReadOnly="True" SortExpression="UserName">
   </asp:boundfield>
   <asp:boundfield DataField="UserEmail" HeaderText="UserEmail" ReadOnly="True" SortExpression="UserEmail">
   </asp:boundfield>
   <asp:boundfield DataField="UserLocation" HeaderText="UserLocation" ReadOnly="True" SortExpression="UserLocation">
   </asp:boundfield>
   <asp:boundfield DataField="UserPhone" HeaderText="UserPhone" ReadOnly="True" SortExpression="UserPhone">
   </asp:boundfield>
   <asp:boundfield DataField="ocd" HeaderText="ocd" ReadOnly="True" SortExpression="ocd">
   </asp:boundfield>
   <asp:boundfield DataField="DepartmentName" HeaderText="DepartmentName" ReadOnly="True" SortExpression="DepartmentName">
   </asp:boundfield>
   <asp:boundfield DataField="UserNH" HeaderText="UserNH" ReadOnly="True" SortExpression="UserNH">
   </asp:boundfield>
   <asp:boundfield DataField="UserSSN" HeaderText="UserSSN" ReadOnly="True" SortExpression="UserSSN">
   </asp:boundfield>
   <asp:checkboxfield DataField="IsRepresentativeInvolved" HeaderText="IsRepresentativeInvolved" ReadOnly="True" SortExpression="IsRepresentativeInvolved">
   </asp:checkboxfield>
   <asp:boundfield DataField="RepresentativeSSN" HeaderText="RepresentativeSSN" ReadOnly="True" SortExpression="RepresentativeSSN">
   </asp:boundfield>
   <asp:boundfield DataField="RepresentativeZipCode" HeaderText="RepresentativeZipCode" ReadOnly="True" SortExpression="RepresentativeZipCode">
   </asp:boundfield>
   <asp:boundfield DataField="OrganizationName" HeaderText="OrganizationName" ReadOnly="True" SortExpression="OrganizationName">
   </asp:boundfield>
   <asp:boundfield DataField="ClaimantName" HeaderText="ClaimantName" ReadOnly="True" SortExpression="ClaimantName">
   </asp:boundfield>
   <asp:checkboxfield DataField="IsProblemQuestion" HeaderText="IsProblemQuestion" ReadOnly="True" SortExpression="IsProblemQuestion">
   </asp:checkboxfield>
   <asp:checkboxfield DataField="IsComment" HeaderText="IsComment" ReadOnly="True" SortExpression="IsComment">
   </asp:checkboxfield>
   <asp:boundfield DataField="ProblemTitle" HeaderText="ProblemTitle" ReadOnly="True" SortExpression="ProblemTitle">
   </asp:boundfield>
   <asp:boundfield DataField="ProblemDescription" HeaderText="ProblemDescription" ReadOnly="True" SortExpression="ProblemDescription">
   </asp:boundfield>
   <asp:boundfield DataField="Attachment" HeaderText="Attachment" ReadOnly="True" SortExpression="Attachment">
   </asp:boundfield>
   <asp:boundfield DataField="TeamMemberName" HeaderText="TeamMemberName" ReadOnly="True" SortExpression="TeamMemberName">
   </asp:boundfield>
   <asp:boundfield DataField="solution" HeaderText="solution" SortExpression="solution">
   </asp:boundfield>
   <asp:boundfield DataField="KnowledgeBaseNotes" HeaderText="KnowledgeBaseNotes" SortExpression="KnowledgeBaseNotes">
   </asp:boundfield>
   <asp:commandfield ShowEditButton="True">
   </asp:commandfield>
     </Fields>
  <HeaderStyle BackColor="Tan" Font-Bold="True" />
  <EditRowStyle BackColor="PaleGoldenrod" ForeColor="Black" />
  <AlternatingRowStyle BackColor="PaleGoldenrod" />
 </asp:DetailsView>
  </div>
 <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:HelpDeskConnectionString %>" SelectCommand="GetInformationForProblemStatusIdforAdmin" SelectCommandType="StoredProcedure" UpdateCommand="InsertOrUpdateAndClosedPSandKB" UpdateCommandType="StoredProcedure">
  <SelectParameters>
   <asp:controlparameter ControlID="GridView1" Name="problemStatusId" PropertyName="SelectedValue" Type="Int32" />
  </SelectParameters>
  <UpdateParameters>
   <asp:parameter Name="KnowledgeBaseNotes" Type="String" />
   <asp:parameter Direction="InputOutput" Name="problem_solution_id" Type="Int32" />
   <asp:parameter Name="ProblemStatusID" Type="Int32" />
   <asp:parameter Name="Solution" Type="String" />
  </UpdateParameters>
 </asp:SqlDataSource>
 <br />
 <div class="style1" style="text-align: left">
 </div>
 <p class="style1"><br />
 </p>
</asp:Content>
<asp:Content id="Content2" runat="server" contentplaceholderid="head">
  <h4 class="style1" style="color: #800000">Please Select a Team Member
  from the List to Edit the Tickets.</h4>
</asp:Content>

 
and here is the error message:
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="Off"/> </system.web> </configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web> </configuration>
 



0
 
LVL 3

Expert Comment

by:OblivionSY
ID: 24357040
Whatever the error is, clearly it is causing problems.

From your code i have a few questions:

1) Where do you declare and instantiate the smtpClient object:

smtpClient.Host = "!!!";
smtpClient.Port = "25";
smtpClient.Credentials = new NetworkCredential(SmtpUserName, SmtpUserPass);
client.EnableSsl = true;
client.Send(message);

You have used "smtpClient" and just "client", maybe this is incorrectly pasted code to the forum, but it is incorrect. (ill assume the !!! is massaged for privacy - sensible!)

2) if you can't get the error to be shown, some shared hosting prevent some settings being overridden, who knows why/if this is one, but you could put a big try catch block around the whole thing and on error, write the exception to the page (don't rethrow the exception) Then post what the actual error is.

Hope this helps
0
 

Author Comment

by:csaexperts
ID: 24357127
azarc3,
after debugging the code, here is the error message i have received
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not ebing configured as an application to IIS
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24358294
Here's part of the problem; you have two customError keys in your web.config file. you should get rid of the first one.

Change this one to:



<!--  *** CHANGE FROM ***  -->

<configuration>

  <system.web>

    <customErrors mode="ReadOnly" defaultRedirect="mycustompage.htm"/>

  </system.web>

</configuration>
 

<!--  *** CHANGE TO ***  -->

<configuration>

  <system.web>

    <customErrors mode="Off" defaultRedirect="mycustompage.htm"/>

  </system.web>

</configuration>

Open in new window

0
 
LVL 11

Expert Comment

by:azarc3
ID: 24358361
My fault; thought that last part was part of your web.config file... disregard my last comment... be back in a bit with a suggestion...
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24358396
See this link: http://forums.asp.net/t/1031775.aspx

Specifically, the part about having a backup of the website in the project without excluding it from the active project?

You're definitely getting a conflict in your configuration... the problem is that we need to determine if the conflict is INSIDE your site or BETWEEN your site and the server's root-level config.
0
 

Author Comment

by:csaexperts
ID: 24359023
azarc3,
Regarding your previous message, For security purpose I havent mentioned the SMTP server name and other things. I checked them again and they are absolutely right SMTP address and email address....
Before you replied to me I checked my directory, i found duplicate web.config which I deleted. Now I am not receiving any error message but still I am not able to send any Email to the User after updating/inserting my records.
I still have the same issue :(
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24359162
Well, at least we're moving in the right direction (we know what's NOT wrong, right?).

Are you certain you're hitting the code that sends the message? Specifically, when you place a breakpoint at the following line: client.Send(message);  --> I don't think you are...

I just took a MUCH closer look at this 'cause something smelled fishy, and I noticed that the SqlDataSourceID for DetailsView1 is SqlDataSource3. However, there's not InsertCommand attribute declared on SqlDataSource3. By some black box magic the INSERT may actually be happening with the InsertOrUpdateAndClosedPSandKB() method that's declared for SqlDataSource3, but it looks like the DetailsView1_ItemInserted event is never being fired. I think if you add the following InsertCommand attribute to SqlDataSource3 it should at least get down into the necessary method.

InsertCommand="InsertOrUpdateAndClosedPSandKB" InsertCommandType="StoredProcedure"

Open in new window

0
 

Author Comment

by:csaexperts
ID: 24359276
azarc3,
For this particular web page I cannot  use insert, I am using Update
 UpdateCommand="InsertOrUpdateAndClosedPSandKB" UpdateCommandType="StoredProcedure"
Even in my SP....I am using Update(if the record is existing) and Insert(If its a new record).
In my detailview do i need to change onItemInserted to OnItemUpdated?
But if i try to change to OnItemUpdated I am getting error message
CS0117: 'System.Web.UI.WebControls.DetailsViewUpdatedEventArgs' does not contain a definition for 'Values'
 Line 12: protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
Line 13: {
Line 14: string problemID = (string)e.Values["ProblemID"];
Line 15: string userName = (string)e.Values["UserName"];
Line 16: string userEmail = (string)e.Values["UserEmail"];
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24359636
Sorry about the delay; just got back in front of a computer.

The Values property doesn't exist in the ItemInserted event. You need to create properties, set them in the ItemInsertING event (using the e.NewValues() property --  which is a Dictionary), and then reference those properties in the ItemInsertED event.
// You'll need properties to hold the values that you're inserting into the database

// You could also do this in ViewState or Session, but why when this is much easier?

// Here are a few properties to get you started; I'm using the v3.5 syntax for brevity
 

private string ProblemID { get; set; }

private string UserName { get; set; }

private string UserEmail { get; set; }

...

// and so on
 

protected void DetailsView1_ItemUpdating(Object sender, DetailsViewUpdateEventArgs e)

{

    // Iterate though the values entered by the user and HTML encode 

    // the values. This helps prevent malicious values from being stored in the data source.
 

    for(int 1 == 0; i < e.Values.Count; i++)

    {

        if(e.NewValues(i) != null)

        {

           // you need to develop some logic to figure out which value to set! Something like...

           switch(e.Keys(i).ToString())

           {

               case "ProblemID":

                  this.ProblemID = Server.HtmlEncode(e.NewValues(i).ToString());

                  break;
 

               case "UserName":

                  this.UserName = Server.HtmlEncode(e.NewValues(i).ToString());

                  break;
 

               case "UserEmail":

                  this.UserEmail = Server.HtmlEncode(e.NewValues(i).ToString());

                  break;
 

               // you'll set the rest of the properties the same way

            }

        }

    }

}
 
 

protected void DetailsView1_ItemUpdating(Object sender, DetailsViewUpdatedEventArgs e)

{

    // Now access the properties you just set in the ItemUpdating method.
 

    // This is where you old code goes, adjusted accordinglingy; for example

    // I'm guessing what some of your properties may be named.

    string problemID = this.ProblemID;

    string userName = this.UserName;

    string userEmail = this.UserEmail;

}

Open in new window

0
 
LVL 11

Expert Comment

by:azarc3
ID: 24359670
I thought about this a little bit more, and you actually probably could pass the whole e.Values() property forward using a single property in your class. If you want to try that then you'll declare just one property and iterate over that one like you tried to do before.


// declare the property

private Dictionary<string, string> MyValues { get; set; }
 

protected void DetailsView1_ItemUpdating(Object sender, DetailsViewUpdateEventArgs e)

{

    // Iterate though the values entered by the user and HTML encode 

    // the values. This helps prevent malicious values from being stored in the data source.

 

    for(int 1 == 0; i < e.Keys.Count; i++)

    {

        if(e.Keys(i) != null && e.NewValues(i) != null)

           MyValues.Add(e.Keys(i).ToString(), e.NewValues(i).ToString());

     }

}

Open in new window

0
 

Author Comment

by:csaexperts
ID: 24363875
azarc3,
In the detail view I am editing only two fields(solution and knowledge base notes) and sending those values as email with other values which are read only = true

In my DetailView1_itemInsert - I am trying to pull all the values which are already there in my detail view by using
string problemID = (string)e.Values["ProblemID"];
string userName = (string)e.Values["UserName"];
and then I am displaying those values in the email which I was trying to send to an user.
 
I tried the above code which you have mentioned, its throwing me an compliation error again

CS0501: 'ASP.teammembers_tmeditproblems4_aspx.MyValues.get' must declare a body because it is not marked abstract or extern  
 // declare the property
private Dictionary<string, string> MyValues { get; set; }
 protected void DetailsView1_ItemUpdating(Object sender, DetailsViewUpdateEventArgs e)
{
 ....}
 
0
 

Author Comment

by:csaexperts
ID: 24363898
azarc3,
is there any other way i can approach and get the output, besides what i tried?
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24364005
Most definitely. However, you've already got your structure in place and believe me or not it's almost "right". Give me a minute to check the compiliation error and I'll be right back.
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24364098
Just realized that you're using ASP.NET 2.0 and not ASP.NET 3.5... had to massage this just a bit to fit your existing code... try the code below. Regardless of the result, just remember that we're almost there.

Sorry about that previous example; I was hacking that at my wife's machine in Notepad and didn't actually build it.  :(
private Dictionary<string, string> _myValues;
 

// declare the property

private Dictionary<string, string> MyValues

{

    get { return _myValues; }

    set { _myValues = value; }

}
 

protected void DetailsView1_ItemUpdating(Object sender, DetailsViewUpdateEventArgs e)

{

    // Iterate though the values entered by the user and HTML encode 

    // the values. This helps prevent malicious values from being stored in the data source.
 

    for (int i = 0; i < e.Keys.Count; i++)

    {

        if (e.Keys[i] != null && e.NewValues[i] != null)

            MyValues.Add(e.Keys[i].ToString(), e.NewValues[i].ToString());

    }

}

Open in new window

0
 

Author Comment

by:csaexperts
ID: 24364198
Thanks a lot for helping me with this problem :) ....
I am still getting compilation error
CS1518: Expected class, delegate, enum, interface, or struct
Line 29: protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
This is what i have done so far
private Dictionary<string, string> MyValues
{
    get { return _myValues; }
    set { _myValues = value; }
}
 
protected void DetailsView1_ItemUpdating(Object sender, DetailsViewUpdateEventArgs e)
{
       for (int i = 0; i < e.Keys.Count; i++)
    {
        if (e.Keys[i] != null && e.NewValues[i] != null)
            MyValues.Add(e.Keys[i].ToString(), e.NewValues[i].ToString());
    }
}
}
protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
string problemID = (string)e.Values["ProblemID"];
string userName = (string)e.Values["UserName"];
string userEmail = (string)e.Values["UserEmail"];
string userLocation = (string)e.Values["UserLocation"];
string userPhone = (string)e.Values["UserPhone"];
string ocd = (string)e.Values["ocd"];
string DepartmentName = (string)e.Values["DepartmentName"];
string UserNH = (string)e.Values["UserNH"];
string UserSSN = (string)e.Values["UserSSN"];
string IsRepresentativeInvolved = (string)e.Values["IsRepresentativeInvolved"];
string RepresentativeSSN = (string)e.Values["RepresentativeSSN"];
string RepresentativeZipCode = (string)e.Values["RepresentativeZipCode"];
string OrganizationName = (string)e.Values["OrganizationName"];
string ClaimantName = (string)e.Values["ClaimantName"];
string IsProblemQuestion = (string)e.Values["IsProblemQuestion"];
string IsComment = (string)e.Values["IsComment"];
string ProblemTitle = (string)e.Values["ProblemTitle"];
string ProblemDescription = (string)e.Values["ProblemDescription"];
string Attachment = (string)e.Values["Attachment"];
string TeamMemberName = (string)e.Values["TeamMemberName"];
string solution = (string)e.Values["solution"];
string KnowledgeBaseNotes = (string)e.Values["KnowledgeBaseNotes"];
 
 
 
0
 

Author Comment

by:csaexperts
ID: 24364221
I have also imported
<%@ Import Namespace="System.Collections.Generic" %>
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24364508
Ok. I went back and setup a test project that is ASP.NET v2.0 and came up with the following.

1. Get rid of the _myValues declaration.
2. Get rid of the MyValues property.
3. Comment out your your DetailsView1_ItemUpdated() method; I think we'll be getting rid of this later.
4. Use the following snippet to set the variable values in your DetailsView1_ItemUpdated() method.

Let me know what happens.
string problemID = e.Keys["ProblemID"].ToString();

string userName = e.Keys["UserName"].ToString();

string userEmail = e.Keys["UserEmail"].ToString();

string userLocation = e.Keys["UserLocation"].ToString();

string userPhone = e.Keys["UserPhone"].ToString();

string ocd = e.Keys["ocd"].ToString();

string DepartmentName = e.Keys["DepartmentName"].ToString();

string UserNH = e.Keys["UserNH"].ToString();

string UserSSN = e.Keys["UserSSN"].ToString();

string IsRepresentativeInvolved = e.Keys["IsRepresentativeInvolved"].ToString();

string RepresentativeSSN = e.Keys["RepresentativeSSN"].ToString();

string RepresentativeZipCode = e.Keys["RepresentativeZipCode"].ToString();

string OrganizationName = e.Keys["OrganizationName"].ToString();

string ClaimantName = e.Keys["ClaimantName"].ToString();

string IsProblemQuestion = e.Keys["IsProblemQuestion"].ToString();

string IsComment = e.Keys["IsComment"].ToString();

string ProblemTitle = e.Keys["ProblemTitle"].ToString();

string ProblemDescription = e.Keys["ProblemDescription"].ToString();

string Attachment = e.Keys["Attachment"].ToString();

string TeamMemberName = e.Keys["TeamMemberName"].ToString();

string solution = e.Keys["solution"].ToString();

string KnowledgeBaseNotes = e.Keys["KnowledgeBaseNotes"].ToString();

Open in new window

0
 

Author Comment

by:csaexperts
ID: 24364599
azarc
I tried the above code, first I didnt see any error, but when I tried to clicking on the update button after editing the problem with Solution and knowledge base notes in it.
Got this compilation error message
System.NullReferenceException: Object reference not set to an instance of an object.
 Line 16: string problemID = e.Keys["ProblemID"].ToString();

0
 
LVL 11

Expert Comment

by:azarc3
ID: 24364710
Yeah; you're going to have to check each one of those to see if there's an actual key/value pair there... I meant to mention that but forgot. So, for example, in the case of ProblemID...

if(e.Keys["ProblemID"] != null)
{
    string problemID = e.Keys["ProblemID"].ToString();
}

You'll need to do that for each one.
0
 

Author Comment

by:csaexperts
ID: 24364849
Tried incorporate the code...got the error message
CS0136: A local variable named 'problemID' cannot be declared in this scope because it would give a different meaning to 'problemID', which is already used in a 'parent or current' scope to denote something else

Line 41:     string problemID = e.Keys["ProblemID"].ToString();

0
 
LVL 11

Expert Comment

by:azarc3
ID: 24364895
Here's your options with that error...

1. Do a find on your page for problemID and make sure "Match case" is checked. That will tell you where the other one(s) is/are and you can decide from there what you want or need to do.

2. The simpler, however, is to remove the declaration cast so your simple setting the value of problemID...

INSTEAD OF THIS:
string problemID = e.Keys["ProblemID"].ToString();

DO THIS:
problemID = e.Keys["ProblemID"].ToString();

The only problem with this approach is that if you need problemID somewhere else and its previous value is necessary then you could be setting yourself up for failure.
0
 

Author Comment

by:csaexperts
ID: 24365121
azarc,
This is what i am trying to achieve in this page:
I was trying to edit a problem (by entering solution and knowledge base notes). After I click on the Update button, Status of the Problem is Closed.
I was trying to send email to the user with all the data ( the information which is there already in Detail view (read only view) and the Solution and knowledge Base notes too). I cannot send the email to the user without Solution and Knowledge Base notes. Which I am trying to achieve. But I dont know how to do that. I thought after update the ticket it will send email. But it doesnt look like that. After clicking on the Update button, Solution and Knowledge Base notes are getting update and the status is changing to closed.
But I am still seeing the error message and no email
System.NullReferenceException: Object reference not set to an instance of an object.
Line 17: UserName = e.Keys["UserName"].ToString();


 This is so much easier to do in core ASP than in .net ...:(
 
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 11

Expert Comment

by:azarc3
ID: 24365603
Did you put the conditional check with each variable, or only on the ProblemID? You're going to have to do it for each one...

The problem is that the values you are looking for are inside of an object, and they aren't guaranteed to be set before you try and evaluate a method on that value (the ToString()). You can't perform an operation on something that doesn't exist, which is what's happening when there's no value for a particular item in the Details View. That's why you have to check each one before you attempt to evaluate it. This is part of why I was saying, "You're almost there" before... there are other ways, but you'd basically have to start from scratch.

So, let's continue down this road and make sure the things we KNOW we have to do aren't the culprit. Use the code below and let's see what the next error is. Just a little more patience; you're getting closer.  :)
if (e.Keys["ProblemID"] != null)

{

    string problemID = e.Keys["ProblemID"].ToString();

}

if (e.Keys["UserName"] != null)

{

    string userName = e.Keys["UserName"].ToString();

}

if (e.Keys["UserEmail"] != null)

{

    string userEmail = e.Keys["UserEmail"].ToString();

}

if (e.Keys["UserLocation"] != null)

{

    string userLocation = e.Keys["UserLocation"].ToString();

}

if (e.Keys["UserPhone"] != null)

{

    string userPhone = e.Keys["UserPhone"].ToString();

}

if (e.Keys["ocd"] != null)

{

    string ocd = e.Keys["ocd"].ToString();

}

if (e.Keys["DepartmentName"] != null)

{

    string DepartmentName = e.Keys["DepartmentName"].ToString();

}

if (e.Keys["UserNH"] != null)

{

    string UserNH = e.Keys["UserNH"].ToString();

}

if (e.Keys["UserSSN"] != null)

{

    string UserSSN = e.Keys["UserSSN"].ToString();

}

if (e.Keys["IsRepresentativeInvolved"] != null)

{

    string IsRepresentativeInvolved = e.Keys["IsRepresentativeInvolved"].ToString();

}

if (e.Keys["RepresentativeSSN"] != null)

{

    string RepresentativeSSN = e.Keys["RepresentativeSSN"].ToString();

}

if (e.Keys["RepresentativeZipCode"] != null)

{

    string RepresentativeZipCode = e.Keys["RepresentativeZipCode"].ToString();

}

if (e.Keys["OrganizationName"] != null)

{

    string OrganizationName = e.Keys["OrganizationName"].ToString();

}

if (e.Keys["ClaimantName"] != null)

{

    string ClaimantName = e.Keys["ClaimantName"].ToString();

}

if (e.Keys["IsProblemQuestion"] != null)

{

    string IsProblemQuestion = e.Keys["IsProblemQuestion"].ToString();

}

if (e.Keys["IsComment"] != null)

{

    string IsComment = e.Keys["IsComment"].ToString();

}

if (e.Keys["ProblemTitle"] != null)

{

    string ProblemTitle = e.Keys["ProblemTitle"].ToString();

}

if (e.Keys["ProblemDescription"] != null)

{

    string ProblemDescription = e.Keys["ProblemDescription"].ToString();

}

if (e.Keys["Attachment"] != null)

{

    string Attachment = e.Keys["Attachment"].ToString();

}

if (e.Keys["TeamMemberName"] != null)

{

    string TeamMemberName = e.Keys["TeamMemberName"].ToString();

}

if (e.Keys["solution"] != null)

{

    string solution = e.Keys["solution"].ToString();

}

if (e.Keys["KnowledgeBaseNotes"] != null)

{

    string KnowledgeBaseNotes = e.Keys["KnowledgeBaseNotes"].ToString();

}

Open in new window

0
 
LVL 11

Expert Comment

by:azarc3
ID: 24365630
If necessary, don't forget to remove the leading "string" on string {variablename} = e.Keys["whatever"].ToString().
0
 

Author Comment

by:csaexperts
ID: 24365981
azarc,
I tried exactly same thing as you have mentioned above, I am checking it for each and every field and even i removed the string too

Here is the error message:
 CS0103: The name 'ProblemStatusId' does not exist in the current context
 Line 16:  ProblemStatusId= e.Keys["ProblemStatusId"].ToString();


protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
 ProblemStatusId= e.Keys["ProblemStatusId"].ToString();
 UserName = e.Keys["UserName"].ToString();
 UserEmail = e.Keys["UserEmail"].ToString();
 UserLocation = e.Keys["UserLocation"].ToString();
 UserPhone = e.Keys["UserPhone"].ToString();
 ocd = e.Keys["ocd"].ToString();
 DepartmentName = e.Keys["DepartmentName"].ToString();
 UserNH = e.Keys["UserNH"].ToString();
 UserSSN = e.Keys["UserSSN"].ToString();
 IsRepresentativeInvolved = e.Keys["IsRepresentativeInvolved"].ToString();
 RepresentativeSSN = e.Keys["RepresentativeSSN"].ToString();
 RepresentativeZipCode = e.Keys["RepresentativeZipCode"].ToString();
 OrganizationName = e.Keys["OrganizationName"].ToString();
 ClaimantName = e.Keys["ClaimantName"].ToString();
 IsProblemQuestion = e.Keys["IsProblemQuestion"].ToString();
 IsComment = e.Keys["IsComment"].ToString();
 ProblemTitle = e.Keys["ProblemTitle"].ToString();
 ProblemDescription = e.Keys["ProblemDescription"].ToString();
 Attachment = e.Keys["Attachment"].ToString();
 TeamMemberName = e.Keys["TeamMemberName"].ToString();
 solution = e.Keys["solution"].ToString();
 KnowledgeBaseNotes = e.Keys["KnowledgeBaseNotes"].ToString();
 
if(e.Keys["ProblemStatusId"] != null)
{
    string ProblemStatusId = e.Keys["ProblemStatusId"].ToString();
}
if(e.Keys["UserName"] != null)
{
     string UserName = e.Keys["UserName"].ToString();
}
if(e.Keys["UserEmail"] != null)
{
     string UserEmail = e.Keys["UserEmail"].ToString();
}
if(e.Keys["UserLocation"] != null)
{
   string UserLocation = e.Keys["UserLocation"].ToString();
}
if(e.Keys["UserPhone"] != null)
{
    string UserPhone = e.Keys["UserPhone"].ToString();
}
if(e.Keys["ocd"] != null)
{
   string  ocd = e.Keys["ocd"].ToString();
}
if(e.Keys["DepartmentName"] != null)
{
    string DepartmentName = e.Keys["DepartmentName"].ToString();
}
if(e.Keys["UserNH"] != null)
{
    string UserNH = e.Keys["UserNH"].ToString();
}
if(e.Keys["UserSSN"] != null)
{
   string  UserSSN = e.Keys["UserSSN"].ToString();
}
if(e.Keys["IsRepresentativeInvolved"] != null)
{
    string IsRepresentativeInvolved = e.Keys["IsRepresentativeInvolved"].ToString();
}
if(e.Keys["RepresentativeSSN"] != null)
{
    string RepresentativeSSN = e.Keys["RepresentativeSSN"].ToString();
}
if(e.Keys["RepresentativeZipCode"] != null)
{
    string RepresentativeZipCode = e.Keys["RepresentativeZipCode"].ToString();
}
if(e.Keys["OrganizationName"] != null)
{
    string OrganizationName = e.Keys["OrganizationName"].ToString();
}
if(e.Keys["ClaimantName"] != null)
{
     string ClaimantName = e.Keys["ClaimantName"].ToString();
}
if(e.Keys["IsProblemQuestion"] != null)
{
    string IsProblemQuestion = e.Keys["IsProblemQuestion"].ToString();
}
if(e.Keys["IsComment"] != null)
{
    string IsComment = e.Keys["IsComment"].ToString();
}
if(e.Keys["ProblemTitle"] != null)
{
    string ProblemTitle = e.Keys["ProblemTitle"].ToString();
}
if(e.Keys["ProblemDescription"] != null)
{
    string ProblemDescription = e.Keys["ProblemDescription"].ToString();
}
if(e.Keys["Attachment"] != null)
{
    string Attachment = e.Keys["Attachment"].ToString();
}
if(e.Keys["TeamMemberName"] != null)
{
    string TeamMemberName = e.Keys["TeamMemberName"].ToString();
}
if(e.Keys["solution"] != null)
{
    string solution = e.Keys["solution"].ToString();
}
if(e.Keys["KnowledgeBaseNotes"] != null)
{
    string KnowledgeBaseNotes = e.Keys["KnowledgeBaseNotes"].ToString();
}
 
 
 
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24366031
It appears you're declaring the same variables twice, and you're not evaluating for a null reference the first time through.

Delete or comment out the following lines at the top of the DetailsView1_ItemUpdated() method...
ProblemStatusId= e.Keys["ProblemStatusId"].ToString();

UserName = e.Keys["UserName"].ToString();

UserEmail = e.Keys["UserEmail"].ToString();

UserLocation = e.Keys["UserLocation"].ToString();

UserPhone = e.Keys["UserPhone"].ToString();

ocd = e.Keys["ocd"].ToString();

DepartmentName = e.Keys["DepartmentName"].ToString();

UserNH = e.Keys["UserNH"].ToString();

UserSSN = e.Keys["UserSSN"].ToString();

IsRepresentativeInvolved = e.Keys["IsRepresentativeInvolved"].ToString();

RepresentativeSSN = e.Keys["RepresentativeSSN"].ToString();

RepresentativeZipCode = e.Keys["RepresentativeZipCode"].ToString();

OrganizationName = e.Keys["OrganizationName"].ToString();

ClaimantName = e.Keys["ClaimantName"].ToString();

IsProblemQuestion = e.Keys["IsProblemQuestion"].ToString();

IsComment = e.Keys["IsComment"].ToString();

ProblemTitle = e.Keys["ProblemTitle"].ToString();

ProblemDescription = e.Keys["ProblemDescription"].ToString();

Attachment = e.Keys["Attachment"].ToString();

TeamMemberName = e.Keys["TeamMemberName"].ToString();

solution = e.Keys["solution"].ToString();

KnowledgeBaseNotes = e.Keys["KnowledgeBaseNotes"].ToString();

Open in new window

0
 
LVL 11

Expert Comment

by:azarc3
ID: 24366070
my bad; just realized why you're doing that... do this instead at the top of the DetailsView1_ItemUpdated() method...
string ProblemStatusId;

string UserName;

string UserEmail;

string UserLocation;

string UserPhone;

string ocd;

string DepartmentName;

string UserNH;

string UserSSN;

string IsRepresentativeInvolved;

string RepresentativeSSN;

string RepresentativeZipCode;

string OrganizationName;

string ClaimantName;

string IsProblemQuestion;

string IsComment;

string ProblemTitle;

string ProblemDescription;

string Attachment;

string TeamMemberName;

string solution;

string KnowledgeBaseNotes;
 

Otherwise you won't be able to access those later on in the method.

Open in new window

0
 

Author Comment

by:csaexperts
ID: 24366504
This is what i have done , Still getting error message
CS0135: 'UserEmail' conflicts with the declaration 'ASP.teammembers_tmeditproblems7_aspx.UserEmail'
 Line 132:message.To.Add(new MailAddress(UserEmail, UserName));


<script runat="server">
string ProblemStatusId;
string UserName;
string UserEmail;
string UserLocation;
string UserPhone;
string ocd;
string DepartmentName;
string UserNH;
string UserSSN;
string IsRepresentativeInvolved;
string RepresentativeSSN;
string RepresentativeZipCode;
string OrganizationName;
string ClaimantName;
string IsProblemQuestion;
string IsComment;
string ProblemTitle;
string ProblemDescription;
string Attachment;
string TeamMemberName;
string solution;
string KnowledgeBaseNotes;
protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
 
if(e.Keys["ProblemStatusId"] != null)
{
    string ProblemStatusId = e.Keys["ProblemStatusId"].ToString();
}
if(e.Keys["UserName"] != null)
{
     string UserName = e.Keys["UserName"].ToString();
}
if(e.Keys["UserEmail"] != null)
{
     string UserEmail = e.Keys["UserEmail"].ToString();
}
if(e.Keys["UserLocation"] != null)
{
   string UserLocation = e.Keys["UserLocation"].ToString();
}
if(e.Keys["UserPhone"] != null)
{
    string UserPhone = e.Keys["UserPhone"].ToString();
}
if(e.Keys["ocd"] != null)
{
   string  ocd = e.Keys["ocd"].ToString();
}
if(e.Keys["DepartmentName"] != null)
{
    string DepartmentName = e.Keys["DepartmentName"].ToString();
}
if(e.Keys["UserNH"] != null)
{
    string UserNH = e.Keys["UserNH"].ToString();
}
if(e.Keys["UserSSN"] != null)
{
   string  UserSSN = e.Keys["UserSSN"].ToString();
}
if(e.Keys["IsRepresentativeInvolved"] != null)
{
    string IsRepresentativeInvolved = e.Keys["IsRepresentativeInvolved"].ToString();
}
if(e.Keys["RepresentativeSSN"] != null)
{
    string RepresentativeSSN = e.Keys["RepresentativeSSN"].ToString();
}
if(e.Keys["RepresentativeZipCode"] != null)
{
    string RepresentativeZipCode = e.Keys["RepresentativeZipCode"].ToString();
}
if(e.Keys["OrganizationName"] != null)
{
    string OrganizationName = e.Keys["OrganizationName"].ToString();
}
if(e.Keys["ClaimantName"] != null)
{
     string ClaimantName = e.Keys["ClaimantName"].ToString();
}
if(e.Keys["IsProblemQuestion"] != null)
{
    string IsProblemQuestion = e.Keys["IsProblemQuestion"].ToString();
}
if(e.Keys["IsComment"] != null)
{
    string IsComment = e.Keys["IsComment"].ToString();
}
if(e.Keys["ProblemTitle"] != null)
{
    string ProblemTitle = e.Keys["ProblemTitle"].ToString();
}
if(e.Keys["ProblemDescription"] != null)
{
    string ProblemDescription = e.Keys["ProblemDescription"].ToString();
}
if(e.Keys["Attachment"] != null)
{
    string Attachment = e.Keys["Attachment"].ToString();
}
if(e.Keys["TeamMemberName"] != null)
{
    string TeamMemberName = e.Keys["TeamMemberName"].ToString();
}
if(e.Keys["solution"] != null)
{
    string solution = e.Keys["solution"].ToString();
}
if(e.Keys["KnowledgeBaseNotes"] != null)
{
    string KnowledgeBaseNotes = e.Keys["KnowledgeBaseNotes"].ToString();
}
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.From = new MailAddress("shruthi.andem@ssa.gov", "System E-mail");
message.To.Add(new MailAddress(UserEmail, UserName));
message.Subject = "Problem submission";
message.Body =
  "Name: " + UserName + "\n" +
  "Email: " + UserEmail + "\n" +
  "Location: " + UserLocation + "\n" +
  "Phone: " + UserPhone + "\n" +
   "DOC: " + ocd + "\n" +
  "ProblemTitle: " + ProblemTitle + "\n" +
  "solution: " + solution + "\n" +
  "KnowledgeBaseNotes: " + KnowledgeBaseNotes + "\n" +
  "ProblemStatusId: " + ProblemStatusId;
 
SmtpClient smtp = new SmtpClient("chinet.ch.as.ssa.gov", 25);
smtp.EnableSsl = false;
//smtp.Credentials = new NetworkCredential("","");
smtp.Send(message);
}
 
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24366619
That's weird. Try using a simple string instead of a variable to see if it is actually the variable causing the problem.

If that works then you may need to rename one of your variables to get rid of the collision that appears to be happening.

Do the following:
message.To.Add("someone@somewhere.com");

Open in new window

0
 

Author Comment

by:csaexperts
ID: 24366690
Azarc,
No it didnt work....
CS0135: 'UserName' conflicts with the declaration 'ASP.teammembers_tmeditproblems7_aspx.UserName'
 
 Line 133:  "Name: " + UserName + "\n" +

0
 
LVL 11

Expert Comment

by:azarc3
ID: 24366776
Ok, there's a pattern developing here. You may need to slightly change the variables you create and set in this method. The names are conflicting because they're exactly the same as the fields in your DetailsView1.
0
 

Author Comment

by:csaexperts
ID: 24369209
azarc3,
This time it was my  bad, I was trying to execute the code at wrong place.
When I tried to execute the code this time again, I am getting this error message:
To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="Off"/> </system.web> </configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web> </configuration>
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24369423
No problem.

In the root level of your application, I assume there is a web.config file. That's the one that should have the <customError mode="Off" /> in it. If you have more than 1 web.config file that is NOT excluded from the application then you need to make sure <customeErrors> is NOT in them.
0
 

Author Comment

by:csaexperts
ID: 24369560
Azarc
I added in my web.config file...and removed the error and able to see the email if i hard code my email address and all the other stuff...But if i try to use UserEmail and UserName....then its throwing error
CS0135: 'UserEmail' conflicts with the declaration 'ASP.teammembers_tmeditproblems7_aspx.UserEmail'
 
Line 128:System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
Line 129:message.From = new MailAddress(san@buy.com, "System E-mail");
Line 130:message.To.Add(new MailAddress(UserEmail, UserName));
Line 131:message.Subject = "Problem submission";
Line 132:message.Body =
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24369750
The problem is that you're doing this in an in-line page, rather than using codebehind. You have to change the name of the variable you're creating in the DetailsView1_ItemUpdated() method to something other than UserEmail... call is theUserEmail and change the references to it in the DetailsView1_ItemUpdated() method. That should work. Don't forget where you're actually referencing the field of DetailsView1 it still needs to be UserEmail.

For example this should work:
string theUserEmail;

if(e.Keys["UserEmail"] != null)
{
    theUserEmail = e.Keys["UserEmail"].ToString();
}

message.To.Add(new MailAddress(theUserEmail, UserName));

Note that UserName in the line above will probably throw an error too...
0
 

Author Comment

by:csaexperts
ID: 24369820
azarc,
I tried that too, I am still getting the same error
CS0135: 'theUserEmail' conflicts with the declaration 'ASP.teammembers_tmeditproblems7_aspx.theUserEmail'
 Line 130:message.To.Add(new MailAddress(theUserEmail, theUserName));

0
 
LVL 11

Expert Comment

by:azarc3
ID: 24370521
Then instead of creating and setting a variable, try using the value directly...
Do this:

message.To.Add(new MailAddress(e.Keys["UserEmail"].ToString(), theUserName));
0
 

Author Comment

by:csaexperts
ID: 24370710
azarc,
Do you want me to delete
if(e.Keys["ProblemStatusId"] != null)
{
   string ProblemStatusId = e.Keys["ProblemStatusId"].ToString();
}
if(e.Keys["UserName"] != null)
{
    string UserName = e.Keys["UserName"].ToString();
}
........
and add directly into the email which you have mentioned above
message.To.Add(new MailAddress(e.Keys["UserEmail"].ToString(), theUserName));
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24373798
No, don't delete all those items!

I suggest you comment ONLY those lines related to "UserEmail" and "UserName" and see if that let's you run the page successfully. That would be the following:
------------------------------------------------------------------------------------------------------------------------
/*
if(e.Keys["UserEmail"] != null)
{
   string UserEmail = e.Keys["UserEmail"].ToString();
}
*/

/*
if(e.Keys["UserName"] != null)
{
   string UserName = e.Keys["UserName"].ToString();
}
*/
------------------------------------------------------------------------------------------------------------------------


Then, when you're creating the message to send, do this:
------------------------------------------------------------------------------------------------------------------------
message.To.Add(new MailAddress(e.Keys["UserEmail"].ToString(), e.Keys["UserName"].ToString());
------------------------------------------------------------------------------------------------------------------------

See how that works.
0
 

Author Comment

by:csaexperts
ID: 24384130
azarc,
I am still getting error :(
 System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

 Line 133:message.To.Add(new MailAddress(e.Keys["UserEmail"].ToString(),e.Keys["UserName"].ToString()));
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24387155
Ok, that narrows the problem significantly. It sounds like you're not actually getting values from DetailsView1 for those fields. Please put a breakpoint at line 133 and debug the page... the objective is to find out if those two keys exist and have data when you are in the DetailsView1_ItemUpdated() method.

Let me know what happens.
0
 

Author Comment

by:csaexperts
ID: 24387583
azarc,
here is the error message:
The name 'UserEmail' does not exist in the current context and The name 'UserName' does not exist in the current context.
But if i run without the Detailview1_itemupdated code , i dont see any errors and i see values are displayed in the grid and detail view :(
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24387731
Are those editable fields in DetailsView1?
0
 

Author Comment

by:csaexperts
ID: 24387842
no they are not editable fields they are read only fields
0
 

Author Comment

by:csaexperts
ID: 24388703
only Knowledgebase and solution fields are editable rest all the fields are read only = true
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24389590
I think that's the problem. Is there a DataKeys property on the DetailsView control? I can't remember. If so we're going to have use it.
0
 

Author Comment

by:csaexperts
ID: 24389822
azarc,
using expression web I created the GUI version of detail view , the datakey propery in the detail view is problemstatusId ;Something like this
http://74.125.47.132/search?q=cache:TzDZh3UWs7sJ:www.asp.net/LEARN/data-access/tutorial-10-vb.aspx+DataKeys+property+on+the+detail+view&cd=1&hl=en&ct=clnk&gl=us
Here is the complete code of the detail view
<asp:DetailsView id="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="ProblemStatusId" DataSourceID="SqlDataSource3" ForeColor="Black" GridLines="None" Height="50px" Width="100%" AllowPaging="True" OnItemUpdated="DetailsView1_ItemUpdated">
  <FooterStyle BackColor="Tan" />
  <PagerStyle BackColor="PaleGoldenrod" ForeColor="#ACA899" HorizontalAlign="Center" />
  <Fields>
   <asp:boundfield DataField="ProblemStatusId" HeaderText="ProblemStatusId" InsertVisible="False" ReadOnly="True" SortExpression="ProblemStatusId">
   </asp:boundfield>
   <asp:boundfield DataField="UserName" HeaderText="UserName" ReadOnly="True" SortExpression="UserName">
   </asp:boundfield>
   <asp:boundfield DataField="UserEmail" HeaderText="UserEmail" ReadOnly="True" SortExpression="UserEmail">
   </asp:boundfield>
   <asp:boundfield DataField="UserLocation" HeaderText="UserLocation" ReadOnly="True" SortExpression="UserLocation">
   </asp:boundfield>
   <asp:boundfield DataField="UserPhone" HeaderText="UserPhone" ReadOnly="True" SortExpression="UserPhone">
   </asp:boundfield>
   <asp:boundfield DataField="ocd" HeaderText="ocd" ReadOnly="True" SortExpression="ocd">
   </asp:boundfield>
   <asp:boundfield DataField="DepartmentName" HeaderText="DepartmentName" ReadOnly="True" SortExpression="DepartmentName">
   </asp:boundfield>
   <asp:boundfield DataField="UserNH" HeaderText="UserNH" ReadOnly="True" SortExpression="UserNH">
   </asp:boundfield>
   <asp:boundfield DataField="UserSSN" HeaderText="UserSSN" ReadOnly="True" SortExpression="UserSSN">
   </asp:boundfield>
   <asp:checkboxfield DataField="IsRepresentativeInvolved" HeaderText="IsRepresentativeInvolved" ReadOnly="True" SortExpression="IsRepresentativeInvolved">
   </asp:checkboxfield>
   <asp:boundfield DataField="RepresentativeSSN" HeaderText="RepresentativeSSN" ReadOnly="True" SortExpression="RepresentativeSSN">
   </asp:boundfield>
   <asp:boundfield DataField="RepresentativeZipCode" HeaderText="RepresentativeZipCode" ReadOnly="True" SortExpression="RepresentativeZipCode">
   </asp:boundfield>
   <asp:boundfield DataField="OrganizationName" HeaderText="OrganizationName" ReadOnly="True" SortExpression="OrganizationName">
   </asp:boundfield>
   <asp:boundfield DataField="ClaimantName" HeaderText="ClaimantName" ReadOnly="True" SortExpression="ClaimantName">
   </asp:boundfield>
   <asp:checkboxfield DataField="IsProblemQuestion" HeaderText="IsProblemQuestion" ReadOnly="True" SortExpression="IsProblemQuestion">
   </asp:checkboxfield>
   <asp:checkboxfield DataField="IsComment" HeaderText="IsComment" ReadOnly="True" SortExpression="IsComment">
   </asp:checkboxfield>
   <asp:boundfield DataField="ProblemTitle" HeaderText="ProblemTitle" ReadOnly="True" SortExpression="ProblemTitle">
   </asp:boundfield>
   <asp:boundfield DataField="ProblemDescription" HeaderText="ProblemDescription" ReadOnly="True" SortExpression="ProblemDescription">
   </asp:boundfield>
   <asp:boundfield DataField="Attachment" HeaderText="Attachment" ReadOnly="True" SortExpression="Attachment">
   </asp:boundfield>
   <asp:boundfield DataField="TeamMemberName" HeaderText="TeamMemberName" ReadOnly="True" SortExpression="TeamMemberName">
   </asp:boundfield>
   <asp:boundfield DataField="solution" HeaderText="solution" SortExpression="solution">
   </asp:boundfield>
   <asp:boundfield DataField="KnowledgeBaseNotes" HeaderText="KnowledgeBaseNotes" SortExpression="KnowledgeBaseNotes">
   </asp:boundfield>
   <asp:commandfield ShowEditButton="True" ShowInsertButton="True">
   </asp:commandfield>
  </Fields>
  <HeaderStyle BackColor="Tan" Font-Bold="True" />
  <EditRowStyle BackColor="PaleGoldenrod" ForeColor="Black" />
  <AlternatingRowStyle BackColor="PaleGoldenrod" />
 </asp:DetailsView>
 
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:HelpDeskConnectionString %>" SelectCommand="GetInformationForProblemStatusIdforAdmin" SelectCommandType="StoredProcedure" UpdateCommand="InsertOrUpdateAndClosedPSandKB" UpdateCommandType="StoredProcedure">
  <SelectParameters>
   <asp:controlparameter ControlID="GridView1" Name="problemStatusId" PropertyName="SelectedValue" Type="Int32" />
  </SelectParameters>
  <UpdateParameters>
   <asp:parameter Name="KnowledgeBaseNotes" Type="String" />
   <asp:parameter Direction="InputOutput" Name="problem_solution_id" Type="Int32" />
   <asp:parameter Name="ProblemStatusID" Type="Int32" />
   <asp:parameter Name="Solution" Type="String" />
  </UpdateParameters>
 </asp:SqlDataSource>
 
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24391252
Using the same debug point, see if there is anything in the e.OldValues property (or if it even exists in DetailsView1_ItemUpdated()). If it doesn't then we'll take a sure route that I KNOW will work... it just requires more hands-on coding than you might be used to.

Also, we know for certain that the message.To.Add() will error; that is fine. The objective is to see if there's anything in the e.OldValues property.

Let me know what happens.
0
 

Author Comment

by:csaexperts
ID: 24391905
azarc3,
I really didnt get you what you have mentioned above, I am new to .net programming. Can you please elaborate it :(
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24394302
No problem at all. I apologize for assuming otherwise.

Going back to your earlier snippets (and combining elements from them), here's what I believe you need to do. If this doesn't work then we'll attack this a different way that I know for a fact will work. I don't want to have to go that route because it might be a little daunting for you. Regardless,  I believe I've got it this time...

If you get errors on any of the fieldnames please make sure that casing is the same in both the DetailsView1_ItemUpdated() method and the DetailsView1 control.

protected void DetailsView1_ItemUpdated(Object sender, DetailsViewUpdatedEventArgs e)

{

    string problemID = (string)e.Keys["ProblemStatusId"];

    

    string userName = (string)e.OldValues["UserName"];

    string userEmail = (string)e.OldValues["UserEmail"];

    string userLocation = (string)e.OldValues["UserLocation"];

    string userPhone = (string)e.OldValues["UserPhone"];

    string ocd = (string)e.OldValues["ocd"];

    string DepartmentName = (string)e.OldValues["DepartmentName"];

    string UserNH = (string)e.OldValues["UserNH"];

    string UserSSN = (string)e.OldValues["UserSSN"];

    string IsRepresentativeInvolved = (string)e.OldValues["IsRepresentativeInvolved"];

    string RepresentativeSSN = (string)e.OldValues["RepresentativeSSN"];

    string RepresentativeZipCode = (string)e.OldValues["RepresentativeZipCode"];

    string OrganizationName = (string)e.OldValues["OrganizationName"];

    string ClaimantName = (string)e.OldValues["ClaimantName"];

    string IsProblemQuestion = (string)e.OldValues["IsProblemQuestion"];

    string IsComment = (string)e.OldValues["IsComment"];

    string ProblemTitle = (string)e.OldValues["ProblemTitle"];

    string ProblemDescription = (string)e.OldValues["ProblemDescription"];

    string Attachment = (string)e.OldValues["Attachment"];

    string TeamMemberName = (string)e.OldValues["TeamMemberName"];

    

    string solution = (string)e.NewValues["solution"];

    string KnowledgeBaseNotes = (string)e.NewValues["KnowledgeBaseNotes"];
 

    MailMessage message = new MailMessage();

    message.From = new MailAddress("shruthi.andem@ssa.gov", "System E-mail");

    message.To.Add(new MailAddress(userEmail, userName));

    message.Subject = "Problem submission";

    message.Body =

      "Name: " + userName + "\n" +

      "Email: " + userEmail + "\n" +

      "Location: " + userLocation + "\n" +

      "Phone: " + userPhone + "\n" +

       "DOC: " + ocd + "\n" +

      "ProblemTitle: " + ProblemTitle + "\n" +

      "solution: " + solution + "\n" +

      "KnowledgeBaseNotes: " + KnowledgeBaseNotes + "\n" +

      "ProblemID: " + problemID;
 

    SmtpClient client = new SmtpClient("!!!", 25);

    client.Credentials = new NetworkCredential(SmtpUserName, SmtpUserPass);

    client.EnableSsl = true;

    client.Send(message);

}

Open in new window

0
 
LVL 11

Expert Comment

by:azarc3
ID: 24394313
Just an FYI...

Although it doesn't tell us exactly how to address your problem, here's an article to read (when you get a chance) to learn a bit more about the DetailsView control: http://msdn.microsoft.com/en-us/library/ms227560(VS.80).aspx.

Don't try to read it all at once. Even with my couple of years of experience I'll usually read parts of them a few times and then come back and read it all again.
0
 

Author Comment

by:csaexperts
ID: 24397673
Thanks azarc  I will definately look at it and try to execute it on monday as I am off this weekend.
0
 

Author Comment

by:csaexperts
ID: 24411670
azarc,
After trying the above code I am still receiving the error :(
Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.

Source Error:

Line 39: string problemID = (string)e.Keys["ProblemStatusId"];
 Line 40:
Line 41: string userName = (string)e.OldValues["UserName"];
0
 
LVL 11

Accepted Solution

by:
azarc3 earned 500 total points
ID: 24411744
That means it should be some type of number then, and it's probably an integer. As an FYI, you can't cast integers to strings. My bad for not catching it before.

Try this at line 39:
string problemID = e.Keys["ProblemStatusId"].ToString();

If that doesn't work then you'll need to debug the page and set a breakpoint at line 39 to figure out what Keys are actually available.
0
 

Author Closing Comment

by:csaexperts
ID: 31580177
Azarc,
Thanks a lot for the help , it worked like a charm :)
I really appreciate your help and time.

0
 

Author Comment

by:csaexperts
ID: 24415045
azarc,
sorry for the trouble again, but I am having problem again.
I tried to add multiline in my solution and Knowledgebasenotes, I am not able to retrieve those values at all...
 <asp:templatefield HeaderStyle-Wrap="true" HeaderText="Solution:">
    <EditItemTemplate>
     <asp:TextBox TextMode="MultiLine" Rows="5" Columns="50" ID="solution" runat="server" Text='<%# Bind("Solution") %>'>
     </asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
     <asp:Label ID="lblSolution" runat="server" Text='<%# Eval("Solution") %>'>
     </asp:Label>
    </ItemTemplate>
   </asp:templatefield>
   <asp:templatefield HeaderStyle-Wrap="true" HeaderText="Knowledge Base Notes:">
    <EditItemTemplate>
     <asp:TextBox TextMode="MultiLine" Rows="5" Columns="50" ID="txtKnowledgeBaseNotes" runat="server" Text='<%# Bind("KnowledgeBaseNotes") %>'>
     </asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
     <asp:Label ID="lblKnowledgeBaseNotes" runat="server" Text='<%# Eval("KnowledgeBaseNotes") %>'>
     </asp:Label>
    </ItemTemplate>
   </asp:templatefield>
 
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24417409
No trouble! Have you reverted back to "single" mode to verify this is actually the problem? I've never run across that before, so we'll have to research it.
0
 
LVL 11

Expert Comment

by:azarc3
ID: 24424342
Some preliminary looking; see if this one helps at all...
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23313709.html
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now