您可以在此情況下,具有3列
它的工作原理大致相同的GridView改用GridView控件的數據列表。
<asp:DataList ID="dlImages" runat="server" RepeatColumns="4" CellPadding="3" CellSpacing="3"
RepeatDirection="Horizontal">
<ItemTemplate>
<table class="TableBorder">
<tr>
<td class="NormalTextBig" valign="top" align="left">
<%#Container.ItemIndex + 1%>.
</td>
</tr>
<tr>
<td valign="top" align="left">
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="ImageClick" CommandArgument='<%# Eval("PageName") %>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
綁定:
Protected Sub dlImages_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlImages.ItemDataBound
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
CType(e.Item.FindControl("ImageButton1"), ImageButton).ImageUrl = "ImageResize.aspx?ImageName=ScreenMasterImages/" & e.Item.DataItem("ImgName") & "&BoxSize=" & 300
CType(e.Item.FindControl("ImageButton1"), ImageButton).ToolTip = e.Item.DataItem("PageName")
End If
End Sub
就像你在我的項目中提到我已經使用了相同的目的,該代碼。
ItemCommand:
Protected Sub dlImages_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlImages.ItemCommand
If e.CommandName = "ImageClick" Then
Session("ImageName") = e.CommandArgument
Response.Redirect("ScreenDetails.aspx")
End If
End Sub
這是怎麼會看:
我想你也有類似的事情:)