Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/363.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
C# 如何从中继器控件检索详细信息以显示在模式弹出窗口中_C#_Javascript_Jquery_Asp.net - Fatal编程技术网

C# 如何从中继器控件检索详细信息以显示在模式弹出窗口中

C# 如何从中继器控件检索详细信息以显示在模式弹出窗口中,c#,javascript,jquery,asp.net,C#,Javascript,Jquery,Asp.net,我有一个中继器控件,它显示一个图像和一些基本信息,如日期时间和产品Id。单击图像时,我需要运行另一个查询,并在单独的弹出窗口中显示详细信息。我知道如何进行弹出。 我想知道如何从中继器获取DateTime和ProductId,并在图像的按钮单击事件中使用它们 我的中继器代码如下: <asp:Repeater ID="rptMonitorSummary" runat="server" OnItemDataBound="rptMonitorSummary_OnItemDataBound">

我有一个中继器控件,它显示一个图像和一些基本信息,如日期时间和产品Id。单击图像时,我需要运行另一个查询,并在单独的弹出窗口中显示详细信息。我知道如何进行弹出。 我想知道如何从中继器获取DateTime和ProductId,并在图像的按钮单击事件中使用它们

我的中继器代码如下:

<asp:Repeater ID="rptMonitorSummary" runat="server" OnItemDataBound="rptMonitorSummary_OnItemDataBound">
    <ItemTemplate>
        <asp:Panel ID="Pnl" runat="server">
            <li class="ui-widget-content ui-corner-tr">
                <h5 class="ui-widget-header">
                    <%# Eval("Name").ToString().Length > 9 ? (Eval("Name") as string).Substring(0, 9) : Eval("Name")%>
                </h5>
                <div id="divHover">
                    <asp:ImageButton Width="80px" ID="btnPerformanceImage" onclick="btnPerformanceImage_Click" runat="server" Height="45px">
                    </asp:ImageButton>
                </div>
                <div class="tooltip" style="display: none">
                    <div style="text-align: center; font-weight: bold;">
                        <%# Eval("DateTime") %><br />
                    </div>
                    <div style="text-align: center; font-weight: normal">
                        ErrorRatingCalls =
                        <%# Eval("ProductId")%><br />
                    </div>
                    <div style="text-align: center; font-weight: normal">
                        TotalRatingCalls =
                        <%# Eval("TotalCalls")%>
                        <br />
                    </div>
                    <div style="text-align: center; font-weight: normal">
                        SuccessRate =
                        <%# Eval("PassPercentage") + "%" %>
                    </div>
                </div>
            </li>
        </asp:Panel>
    </ItemTemplate>
</asp:Repeater>

我只想知道如何获取已绑定到repeater控件的值,当我单击repeater控件内的图像时,您可以为包含日期值和ProductId值的两个div标记设置类属性名称,然后使用jquery.find('classname')获取它们检索它们的值。

您可以为包含日期值和ProductId值的两个div标记设置类属性名称,然后使用jquery获取它们。find('classname')检索它们的值。

使用事件从repeater控件中提取值

<asp:Repeater ID="rptMonitorSummary" runat="server" OnItemDataBound="rptMonitorSummary_OnItemDataBound" OnItemCommand="rptMonitorSummary_ItemCommand">
使用事件从中继器控件中提取值

<asp:Repeater ID="rptMonitorSummary" runat="server" OnItemDataBound="rptMonitorSummary_OnItemDataBound" OnItemCommand="rptMonitorSummary_ItemCommand">

在中继器中使用OnItemCommand=“rptMonitorSummary\u itemcond”,而不是在按钮内单击

然后在代码背后

    protected void rptMonitorSummary_ItemCommand(object sender, RepeaterCommandEventArgs e)
    {
          //  e.CommandName and e.CommandArgument will let you know what was clicked
    }
你的按钮可能看起来像这样

    <asp:Button runat="server" ID="btnPerformanceImage" Text="Whatever" CommandName="OpenImage" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ProductId") %>' />


这样,您就知道用户单击了什么,并且可以更改弹出窗口以适应它,而不是单击按钮内部的按钮,在中继器中使用OnItemCommand=“rptMonitorSummary\u ItemCommand”

然后在代码背后

    protected void rptMonitorSummary_ItemCommand(object sender, RepeaterCommandEventArgs e)
    {
          //  e.CommandName and e.CommandArgument will let you know what was clicked
    }
你的按钮可能看起来像这样

    <asp:Button runat="server" ID="btnPerformanceImage" Text="Whatever" CommandName="OpenImage" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ProductId") %>' />


这样您就知道用户单击了什么,并且可以更改弹出窗口以适应它

而不是处理按钮本身的单击,您应该使用
中继器
控件的
项命令
事件。作为
CommandArgument
您可以传递
ProductId
,然后在处理程序内部使用它从数据库检索其余信息。或者,您甚至可以将所有需要的值作为单个字符串包含到
CommandArgument
中,然后进行一些解析:

<asp:Repeater ... OnItemCommand="rptMonitorSummary_ItemCommand" ... >
   ...
   <asp:ImageButton ... CommandName="ShowPopup" CommandArgument='<%# Eval("ProductId") + "," + Eval("DateTime") %>'>
   </asp:ImageButton>
   ...
</asp:Repeater>

您应该使用
中继器
控件的
ItemCommand
事件,而不是处理单击按钮本身。作为
CommandArgument
您可以传递
ProductId
,然后在处理程序内部使用它从数据库检索其余信息。或者,您甚至可以将所有需要的值作为单个字符串包含到
CommandArgument
中,然后进行一些解析:

<asp:Repeater ... OnItemCommand="rptMonitorSummary_ItemCommand" ... >
   ...
   <asp:ImageButton ... CommandName="ShowPopup" CommandArgument='<%# Eval("ProductId") + "," + Eval("DateTime") %>'>
   </asp:ImageButton>
   ...
</asp:Repeater>