【发布时间】:2014-07-31 12:07:40
【问题描述】:
我的网络表单应用在更新面板中有一个数据列表,数据列表包含:{imagebutton, label,label}。 datalist 连接到银行。在 imagebutton 中将显示图像的缩略图。我希望当用户单击数据列表中的每个图像按钮时,将显示原始图像。 所有数据都成功显示在数据列表中,但问题在于单击图像按钮后。我不能继续。如何检测单击了哪个图像按钮?它的数据源是什么?同一单元格中的实验室的文本或数据源是什么?
请帮帮我,我的代码很糟糕:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="content">
<div class="datashow">
<asp:DataList ID="DataList1" runat="server" BorderColor="#666666" BorderStyle="None" BorderWidth="2px" CellPadding="2" CellSpacing="2" Font-Size="Small" RepeatDirection="Horizontal" CssClass="dl" HorizontalAlign="Center" RepeatColumns="5">
<HeaderStyle BackColor="#333333" Font-Bold="True" Font-Size="Large" ForeColor="White" HorizontalAlign="Center" Wrap="True" />
<ItemTemplate>
<asp:ImageButton ID="imgbtn" runat="server" ImageUrl='<%# Bind("imgtp","~/images/{0}") %>' Width="100px" OnClick="imgbtn_Click" />
<br />
<b>Employee Name:</b>
<asp:Label ID="lblCName" runat="server" Text='<%# Bind("name") %>'></asp:Label>
<br />
<b>Designation:</b>
<asp:Label ID="lblName" runat="server" Text='<%# Bind("company") %>'></asp:Label>
</ItemTemplate>
</asp:DataList>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
和
protected void imgbtn_Click(object sender, ImageClickEventArgs e)
{
//how to detect which imagebtn clicked and what is its datasource?
}
【问题讨论】:
-
您的观察结果是什么?
imgbtn_Click中的代码执行了吗?! -
如果您打算成为一名优秀的 SO 公民,请在发布问题之前尝试“搜索”已发布的可能与您的问题相关的问题:stackoverflow.com/a/18522585/145682
-
如何在 updatepanel 内但在按钮单元格外找到一个 div?
-
尝试递归迭代
UpdatePanel1.Controls
标签: c# asp.net sql-server datalist