Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I am using a pop control extender to show a popup with extended details from a grid view.

Now whenever i do mouseover on the select button of my grid, a message would popup, "Web service call failed:500".

I am not finding any solution for this problem, please help me!

Thanks in Advance!

Ahsan

My code is:


using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using AjaxControlToolkit;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            LoadData();
        }
    }
    private void LoadData()
    {
        string constr = "Server=Ahsan-PC;Database=SampleDatabase;INtegrated Security = true;";
        string query = "SELECT ProductID, ProductName FROM Products";
        SqlDataAdapter da = new SqlDataAdapter(query, constr);
        DataTable table = new DataTable();
        da.Fill(table);
        GridView1.DataSource = table;
        GridView1.DataBind();
    }
    protected void GridView1_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 contextKey)
    {
        string constr = "Server=Ahsan-PC;Database=SampleDatabase;";
        string query = "SELECT UnitPrice, UnitsInStock, Description FROM Products WHERE ProductID = '"+contextKey+"'";
        SqlDataAdapter da = new SqlDataAdapter(query, constr);
        DataTable table = new DataTable();
        da.Fill(table);
        StringBuilder b = new StringBuilder();
        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>Product Details</b>"); b.Append("</td></tr>");
        b.Append("<tr><td style='width:80px;'><b>Unit Price</b></td>");
        b.Append("<td style='width:80px;'><b>Stock</b></td>");
        b.Append("<td><b>Description</b></td></tr>");
        b.Append("<tr>");
        b.Append("<td>$" + table.Rows[0]["UnitPrice"].ToString() + "</td>");
        b.Append("<td>" + table.Rows[0]["UnitsInStock"].ToString() + "</td>");
        b.Append("<td>" + table.Rows[0]["Description"].ToString() + "</td>");
        b.Append("</tr>");
        b.Append("</table>");
        return b.ToString();
    }
}
Posted
Updated 8-Jul-11 4:24am
v2
Comments
[no name] 8-Jul-11 11:26am    
And have you debugged?
Parwej Ahamad 8-Jul-11 11:51am    
Seems issue is in your call method OR may be not providing correct location.

Here you go.

This post also contains details about the below errors(Middle of the post)
1. Web Service call failed: 12030
2. Web Service call failed: 500

Working with Modal Popup extender control.[^]
 
Share this answer
 
You are missing WebMethod attribute:

[System.Web.Services.WebMethod()]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900