那应该很简单。在项目模板中配置您的图像按钮并为其提供 CommandName 和 CommandArgument(绑定到 ID):
...
<ItemTemplate>
...
<asp:ImageButton runat="server" id="foobar" CommandName="DownloadPDF" CommandArgument='"<%# Eval( "AccountID" ) #>' />
</ItemTemplate>
然后,添加OnItemCommand到您的 ListView:
<asp:ListView .... OnItemCommand="TheListView_ItemCommand"
并实现它以捕获DownloadPDF来自子控件(ImageButton)的通知:
protected void TheListView_ItemCommand( object sender, ListViewCommandEventArgs e )
{
switch ( e.CommandName )
{
case "DownloadPDF":
string accountID = e.CommandArgument;
// now create the PDF and send it back to the client
break;
}
}