日期:2014-05-17 浏览次数:20487 次
<table class="ProTab marginT" border="0" cellspacing="0" cellpadding="0" width="245px"> <tbody> <tr> <th> 品名</th> <th>价格</th> <th>发布日期</th> </tr> <asp:Repeater ID="repPro" runat="server" OnItemDataBound="repPro_ItemDataBind"> <ItemTemplate> <tr> <td style="height: 24px" ><a title="<%# Eval("Name") %>" href="#"> <%# Eval("Name") %></a></td> <!--需要控制权限是否显示--> <div id="guoji" runat="server" visible="true"> <td style="height: 24px" > <%# Eval("price") %></td> </div><!--需要控制权限是否显示--> <td style="height: 24px" > <%# Eval("Addtime") %></td> </ItemTemplate></asp:Repeater> </tbody></table>
public void Rep3() { string sql = "select top 15 * from Products order by classid desc"; SqlDataAdapter da = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet(); da.Fill(ds, "a"); this.repPro.DataSource = ds.Tables["a"].DefaultView; this.repPro.DataBind(); //绑定输出数据 } protected void repPro_ItemDataBind(object sender, RepeaterItemEventArgs e) { if (Session["UserName"] != null) { if (Session["UserName"].ToString() == "") { e.Item.FindControl("guoji").Visible = false; } } }