Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.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# 如何在asp超链接中包含查询字符串_C#_Asp.net_Webforms - Fatal编程技术网

C# 如何在asp超链接中包含查询字符串

C# 如何在asp超链接中包含查询字符串,c#,asp.net,webforms,C#,Asp.net,Webforms,我正在尝试在asp.net超链接中发送查询字符串我不确定这是否可能?我在一个集合中循环,我想包括集合中每个对象的id。当前上下文中不存在im获取p的错误。这是我的密码 <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <div class="container" style="margin-top:50px;"> <asp:Lab

我正在尝试在asp.net超链接中发送查询字符串我不确定这是否可能?我在一个集合中循环,我想包括集合中每个对象的id。当前上下文中不存在im获取p的错误。这是我的密码

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="container" style="margin-top:50px;">
    <asp:Label ID="label1" runat="server"></asp:Label>
    <div class="jumbotron" style="margin:100px;width:900px">

    <% foreach (var p in products)
       {
            %> <!-- loop through the list -->

  <ul style="display:inline-block;width:250px;height:300px;list-style-type:none;border-style:solid">
    <li ">

        <p><%= p.ProductName %></p>
        <p>€<%= p.Price %></p>
        <img src="<%= p.MainProductImage %>" width="150";height="150";/>
        <br />
        <asp:HyperLink ID="details" runat="server" Text="Details" NavigateUrl='<%#string.Format("ProductDetails.aspx?ProductID={0}", p.ProductID);%>' />

    </li>
    </ul>
            <% 
         }
      %>

</div>
</div>


而不是
您是否尝试过使用简单的锚定标记
而不是
超链接
控件?
<a href='<%=string.Format("ProductDetails.aspx?ProductID={0}", p.ProductID);%>' alt="Details" >Details</a>