GridView
<asp:GridView ID="GridView1" runat="server"
CssClass="GridViewStyle" PageSize="10" AllowPaging="true"
onpageindexchanging="GridView1_PageIndexChanging"
onrowcommand="GridView1_RowCommand">
<FooterStyle CssClass="GridViewFooterStyle" />
<RowStyle CssClass="GridViewRowStyle" />
<SelectedRowStyle CssClass="GridViewSelectedRowStyle" />
<PagerStyle CssClass="GridViewPagerStyle" />
<AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" />
<HeaderStyle CssClass="GridViewHeaderStyle"/>
<Columns>
<asp:BoundField DataField="DRName" HeaderText="饭店名称" />
<asp:BoundField DataField="Category" HeaderText="所属菜系" />
<asp:BoundField DataField="ConsumptionLevel" HeaderText="人均消费" />
<asp:BoundField DataField="Remark" HeaderText="折扣" ControlStyle-Width="80px" />
<asp:BoundField DataField="Telephone" HeaderText="联系电话" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnDetails" runat="server" Text="详细" CommandName="GetID"
CommandArgument='<%#eval_r("ID") %>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
提示:当前没有任何记录
</EmptyDataTemplate>
</asp:GridView>
protected void
GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
int id = Convert.ToInt32(e.CommandArgument);
switch (e.CommandName)
{
case "GetID":
Server.Transfer("iframeRepeater.aspx?ID=" + id.ToString());
break;
}
}
catch
{ }
}
DataList
<asp:DataList ID="DataList1" runat="server" BorderColor="#CCCCCC" BorderStyle="None"
BorderWidth="0" CellPadding="3" GridLines="Both" RepeatColumns="3"
RepeatDirection="Horizontal"
Width="99%" HorizontalAlign="Center" ItemStyle-BorderWidth="1"
onitemcommand="DataList1_ItemCommand" >
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#669999"></SelectedItemStyle>
<ItemStyle ForeColor="#000066" VerticalAlign="Top" Width="33%"></ItemStyle>
<ItemTemplate>
<table cellpadding="1" cellspacing="0" height="220" border="0" width="80%">
<tr>
<td align="center" style="height: 95px">
<a href='Repeater.aspx?num=<%#eval_r("shopNum") %>'>
<img src='<%#eval_r("ShopImage") %>' height="250px"
width="250px" /></a>
</td>
</tr>
<tr>
<td align="center">
<a href='Repeater.aspx?num=<%#eval_r("shopNum")%>'>
<%#eval_r("shopName")%></a>
</td>
</tr>
<tr>
<td align="center">
<%#eval_r("shopPhone")%>
<asp:Button ID="btnDetails" runat="server" Text="详细"
CommandName="showDetails" CommandArgument='<%#Eval
("shopNum") %>'/>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
try
{
string num = e.CommandArgument.ToString();
switch (e.CommandName)
{
case "showDetails":
Server.Transfer("Repeater.aspx?num=" + num);
break;
}
}
catch { }
}