Hi,
I am having this error "Web Service Call Failed: 500".
I am using an AJAX PopupControlExtender which would show a popup once mouseover on an image in row of a grid view occurs.
Now, when mouseover occurs, i receive this error.
Please help me as i am really stuck!
Thanks
CODE:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Services;
using Sales_DAL;
using Sales_BOL;
using AjaxControlToolkit;
using System.Text;
using System.Web.Services.Description;
public partial class MCTX_Internal_SuperAdmin_frmShowDailyOutput : System.Web.UI.Page
{
Dlayer dl = new Dlayer();
_DailyOutput objDO = new _DailyOutput();
_ShowDailyOutput bl = new _ShowDailyOutput();
DataTable dt_Grid = new DataTable();
string userid;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetEmpName();
DataTable dtUserID = new DataTable();
dtUserID = bl.selectuserid();
ddlEmployees.DataSource = dtUserID;
ddlEmployees.DataTextField = "user_id";
ddlEmployees.DataBind();
ddlEmployees.Items.Insert(0, "---Select---");
}
}
public void GetEmpName()
{
string str = Session["Username"].ToString();
DataTable dt_Name = objDO.fnGetEmpName(str);
lblEmpName.Text = dt_Name.Rows[0]["E_Name"].ToString();
lblEmpName.ForeColor = System.Drawing.Color.Magenta;
}
protected void btnShow_Click(object sender, EventArgs e)
{
if (FromDate.SelectedValue == null || ToDate.SelectedValue == null)
{
lblError.Text = "Please Select From/To Dates";
lblError.ForeColor = System.Drawing.Color.Red;
gvShowDailyOutput.Visible = false;
}
else if (ddlEmployees.SelectedItem.Text == " ---Select--- ")
{
lblError.Text = "Please Select Employee";
lblError.ForeColor = System.Drawing.Color.Red;
gvShowDailyOutput.Visible = false;
}
else
{
DataTable dttest = new DataTable();
dttest = Results();
if (dt_Grid.Rows.Count > 0)
{
if (!IsPostBack)
{
}
gvShowDailyOutput.DataSource = dt_Grid;
gvShowDailyOutput.DataBind();
lblError.Text = string.Empty;
gvShowDailyOutput.Visible = true;
}
else
{
gvShowDailyOutput.Visible = false;
lblError.Text = "No Record Found";
lblError.ForeColor = System.Drawing.Color.Red;
}
}
}
public DataTable Results()
{
DateTime FrmDate = new DateTime();
FrmDate = FromDate.SelectedDate;
DateTime TDate = new DateTime();
TDate = ToDate.SelectedDate;
userid = ddlEmployees.SelectedItem.Text;
dt_Grid = bl.selectGridData(userid, FrmDate, TDate);
return dt_Grid;
}
protected void gvShowDailyOutput_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvShowDailyOutput.PageIndex = e.NewPageIndex;
Results();
gvShowDailyOutput.DataSource = dt_Grid;
gvShowDailyOutput.DataBind();
}
protected void gvShowDailyOutput_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
PopupControlExtender pce = e.Row.FindControl("PopupControlExtender1") as PopupControlExtender;
string behaviorID = "pce_" + e.Row.RowIndex;
pce.BehaviorID = behaviorID;
Image img = (Image)e.Row.FindControl("Image1");
string OnMouseOverScript = string.Format("$find('{0}').showPopup();", behaviorID);
string OnMouseOutScript = string.Format("$find('{0}').hidePopup();", behaviorID);
img.Attributes.Add("onmouseover", OnMouseOverScript);
img.Attributes.Add("onmouseout", OnMouseOutScript);
}
}
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string GetDynamicContent(string DynamicContextKey)
{
DropDownList ddlEmployees = new DropDownList();
StringBuilder b = new StringBuilder();
DataTable table = new DataTable();
_ShowDailyOutput sdo = new _ShowDailyOutput();
table = sdo.selectPopupData(ddlEmployees.SelectedItem.Text, DynamicContextKey);
b.Append("<table style='background-color:#f3f3f3; border: #336699 3px solid; ");
b.Append("width:350px; font-size:10pt; font-family:Verdana;' cellspacing='0' cellpadding='3'>");
b.Append("<tr><td colspan='3' style='background-color:#336699; color:white;'>");
b.Append("<b>Report Details</b>"); b.Append("</td></tr>");
b.Append("<tr><td style='width:80px;'><b>Hour No</b></td>");
b.Append("<tr><td style='width:80px;'><b>From Time</b></td>");
b.Append("<tr><td style='width:80px;'><b>To Time</b></td>");
b.Append("<tr><td style='width:80px;'><b>Report Time</b></td>");
b.Append("<tr><td style='width:80px;'><b>Activity</b></td>");
b.Append("<tr>");
b.Append("<td>$" + table.Rows[0]["hourNo"].ToString() + "</td>");
b.Append("<td>" + table.Rows[0]["fromTime"].ToString() + "</td>");
b.Append("<td>" + table.Rows[0]["rptTime"].ToString() + "</td>");
b.Append("<td>" + table.Rows[0]["TaskDetails"].ToString() + "</td>");
b.Append("</tr>");
b.Append("</table>");
return b.ToString();
}
}
public class _ShowDailyOutput
{
Dlayer dl = new Dlayer();
string query;
public DataTable selectuserid()
{
DataTable dt = new DataTable();
query = "select user_id from user1";
dt = dl.DA_getTable(query);
return dt;
}
public DataTable selectGridData(string UserID, DateTime FrmDate, DateTime TDate)
{
DataTable dt = new DataTable();
query = "select CONVERT(varchar(20),currentdate,101) AS CurrentDate ,DailyReport.DailyReport_ID, DailyReport.MyOutput from DailyReport INNER JOIN ReportDetails on ReportDetails.DailyReport_ID = DailyReport.DailyReport_ID where user_id = '" + UserID + "' and CurrentDate between '" + FrmDate + "' and '" + TDate + "'";
dt = dl.DA_getTable(query);
return dt;
}
public DataTable selectPopupData(string ReportID, string ContextKey)
{
string query;
Dlayer dl = new Dlayer();
DataTable dt = new DataTable();
query = "select ReportDetails.hourNo, ReportDetails.fromtime, ReportDetails.toTime, ReportDetails.rptTime, ReportDetails.TaskDetails from ReportDetails Inner Join DailyReport on ReportDetails.DailyReport_ID = DailyReport.DailyReport_ID where DailyReport.DailyReport_ID = '" + ReportID + "' and user_id = '" + ContextKey + "'";
dt = dl.DA_getTable(query);
return dt;
}
}