在asp.net中设计通知部分

时间:2016-07-19 16:22:38

标签: asp.net asprepeater

我正在尝试为我的ASP.NET网站设计一个通知部分。 我的要求与this image layout类似。 我能够使用asp转发器控件实现它并将其与数据库绑定。 我的数据库中有表格,其中包含图像,名称和注释。 所以根据没有。在DB表中的行中,转发器控件将获取定义布局中的内容。

但我也想实现关闭按钮(“X” - 右上角)。此关闭按钮将删除特定注释(但不会删除数据库中的数据)。 能帮我实现这个吗? 还要感谢建议任何其他可能的选项来实现这一点。 PFB到目前为止我已完成的代码

  <asp:Repeater ID="Repeater1" runat="server">
  <ItemTemplate>
  <table>
  <tr>
  <td style="height:64px;width:64px">
  <asp:Image  ID="imgEmployee" CssClass="imgClass" ImageUrl='<%# Eval("ImagePath")%>'runat="server" />
  </td>
  <td>
  <asp:Label runat="server" Text='<%# Eval("Name")%>'></asp:Label>
  <p> <%# Eval("Comments")%></p>
  </td>
  </tr>
  </table>
  </ItemTemplate>
  </asp:Repeater>

和背后的代码

  protected void Page_Load(object sender, EventArgs e)
  {
    DataSet ds = GetData();
    Repeater1.DataSource = ds;
    Repeater1.DataBind();
  }
  private DataSet GetData()
  {
    string CS = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
    using (SqlConnection con = new SqlConnection(CS))
    {
        SqlDataAdapter da = new SqlDataAdapter("Select * from tblNotification", con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        return ds;
    }
  }

我的表(tblNotification)有3列 - “ImagePath”,“Name”和“Comments”

0 个答案:

没有答案