Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 在gridview中将鼠标移动到行上时显示详细信息?_Asp.net_Gridview_Mouseover - Fatal编程技术网

Asp.net 在gridview中将鼠标移动到行上时显示详细信息?

Asp.net 在gridview中将鼠标移动到行上时显示详细信息?,asp.net,gridview,mouseover,Asp.net,Gridview,Mouseover,我使用的是gridview,如果我将鼠标指向每一行,我需要在弹出窗口的表格/网格中显示特定的细节。 我尝试了以下代码,但在弹出窗口中仅显示一行: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { PopupControlExtender pce = e.Row

我使用的是gridview,如果我将鼠标指向每一行,我需要在弹出窗口的表格/网格中显示特定的细节。 我尝试了以下代码,但在弹出窗口中仅显示一行:

 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 = ConfigurationSettings.AppSettings["ConnectionInfo"];
        SqlConnection con = new SqlConnection(constr);
        con.Open();
        string query = "SELECT * FROM Table1 WHERE field1 = '" + contextKey + "' ";

        SqlDataAdapter da = new SqlDataAdapter(query, con);
        DataTable table = new DataTable();

        da.Fill(table);

        StringBuilder b = new StringBuilder();
    b.Append("<table border='1' style='background-color:#f3f3f3; ");
    b.Append("width:350px; font-size:10pt; font-family:Verdana;' cellspacing='0' cellpadding='3'>");

    b.Append("<tr style = 'background-image: url(Images/HeaderGlassBlack.jpg); background-repeat:repeat; color:#FFC700; '><td style='width:50px;'><b>Employee</b></td>");
    b.Append("<td style='width:80px;'><b>KPI Name</b></td>");
    b.Append("<td style='width:80px;'><b>Business</b></td>");
    b.Append("<td style='width:80px;'><b>Description</b></td>");

    b.Append("<td style='width:50px;'><b>Plan Live</b></td>");
    b.Append("<td style='width:80px;'><b>Actual Live</b></td>");
    b.Append("<td style='width:80px;'><b>Plan Q1</b></td>");
    b.Append("<td style='width:80px;'><b>Actual Q1</b></td></tr>");

    b.Append("<tr>");
    b.Append("<td>" + table.Rows[0]["Emp_Name"].ToString() + "</td>");
    b.Append("<td>" + table.Rows[0]["kpi_name"].ToString() + "</td>");
    b.Append("<td>" + table.Rows[0]["Bus_Name"].ToString() + "</td>");
    b.Append("<td>" + table.Rows[0]["Description"].ToString() + "</td>");
    b.Append("<td>" + table.Rows[0]["PLAN_LIVE"].ToString() + "</td>");
    b.Append("<td>" + table.Rows[0]["ACTUAL_LIVE"].ToString() + "</td>");
    b.Append("<td>" + table.Rows[0]["PLAN_Q1"].ToString() + "</td>");
    b.Append("<td>" + table.Rows[0]["ACTUAL_Q1"].ToString() + "</td>");


    b.Append("</tr>");

    b.Append("</table>");

    return b.ToString();
}
protectedvoid GridView1\u RowCreated(对象发送方,GridViewRowEventArgs e)
{
如果(e.Row.RowType==DataControlRowType.DataRow)
{
PopupControlExtender pce=e.Row.FindControl(“PopupControlExtender 1”)作为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);
Add(“onmouseover”,onmouseover脚本);
Add(“onmouseout”,OnMouseOutScript);
}
}
[System.Web.Services.WebMethodAttribute(),
System.Web.Script.Services.ScriptMethodAttribute()]
公共静态字符串GetDynamicContent(字符串contextKey)
{
string constr=ConfigurationSettings.AppSettings[“ConnectionInfo”];
SqlConnection con=新的SqlConnection(cont);
con.Open();
string query=“从表1中选择*,其中field1=”+contextKey+”;
SqlDataAdapter da=新的SqlDataAdapter(查询,con);
DataTable=新的DataTable();
da.填写(表格);
StringBuilder b=新的StringBuilder();
b、 附加(“”);
b、 附加(“雇员”);
b、 附加(“KPI名称”);
b、 附加(“业务”);
b、 附加(“说明”);
b、 附加(“现场计划”);
b、 附加(“实际现场”);
b、 附加(“计划Q1”);
b、 附加(“实际Q1”);
b、 附加(“”);
b、 追加(“+table.Rows[0][“Emp_Name”].ToString()+”);
b、 追加(“+table.Rows[0][“kpi_name”].ToString()+”);
b、 追加(“+table.Rows[0][“Bus_Name”].ToString()+”);
b、 追加(“+table.Rows[0][“Description”].ToString()+”);
b、 追加(“+table.Rows[0][“PLAN_LIVE”].ToString()+”);
b、 追加(“+table.Rows[0][“ACTUAL_LIVE”].ToString()+”);
b、 追加(“+table.Rows[0][“PLAN_Q1”].ToString()+”);
b、 追加(“+table.Rows[0][“ACTUAL_Q1”].ToString()+”);
b、 附加(“”);
b、 附加(“”);
返回b.ToString();
}

我知道我需要遍历数据集来填充dymanic表中的所有值,但我不知道如何实现这一点。有人能帮忙吗?

您可以尝试使用此代码

b.Append("<table>");
//Here you add attributes of table
.... 
foreach(var row in table.Rows)
{

    b.Append("<tr>");
    b.Append("<td>");
    b.Append(row["Emp_Name"].ToString());
    b.Append("</td>"); 
    //here you add your differents cells
    .......
    b.Append("</tr>");
}
//Close your table
b.Append("</table>");

.... 
b.Append(“”);
//在这里添加表的属性
.... 
foreach(表中的变量行。行)
{
b、 附加(“”);
b、 附加(“”);
b、 追加(行[“Emp_Name”].ToString());
b、 附加(“”);
//在这里,您可以添加不同的单元格
.......
b、 附加(“”);
}
//关上你的桌子
b、 附加(“”);
.... 

为什么不使用AjaxToolkit

你能创建html表格吗?是的,我正在生成html表格。可能我需要对dataadapter中生成的行进行计数,并使用该计数在html表中循环。不起作用。我甚至尝试了绑定gridview而不是html表,希望所有行都被绑定,但没有任何用处。你的解决方案奏效了!!然而,我不得不做一个更改,我在Foreach条件中使用了DataRow而不是var。非常感谢。我很乐意帮助你。谢谢