Click here to Skip to main content
15,898,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

XML
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 7-Jul-11 23:44pm
v5
Comments
Prerak Patel 8-Jul-11 3:03am    
Share relevant code.
shefeekcm 8-Jul-11 3:03am    
Please share your code.
Ahsan Mirza 8-Jul-11 10:21am    
I have shared the code, now anyone help please!

A status 500 error indicates that there was a server error.
So please post your code then only we can guide you where you went wrong.
 
Share this answer
 
Comments
Ahsan Mirza 8-Jul-11 6:32am    
I have posted my code, please help me now!
Ahsan Mirza 8-Jul-11 9:39am    
I have posted my code brother :(
use an updatepanel for the panel of modelpopup extender.
 
Share this answer
 
 
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