用户明智地显示Listview中的数据

时间:2015-02-16 09:34:29

标签: c# html asp.net listview

首先。我有3个标签,

作为

<ul class='tabs1'>
            <li><a href='#tab1'>All News</a></li>

            <li><a href='#tab2'>For NGO</a></li>
            <li><a href='#tab3'>From NGO</a></li>
        </ul>

默认显示#tab1 数据。其他两个选项卡的逻辑显示为User wise。

如果SuperAdmin上传数据,则数据应显示在FOR NGO中,如果

管理员&amp;用户上传数据,然后数据应显示在FROM NGO。

我已将角色赋予他们

*超级管理员 - &gt; 0  管理员 - &gt; 1 用户 - &gt; 2。

对于所有用户的显示,我有这样的代码: -

private void BindNews()
    {
        using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
        {
            string query = query = "SELECT dbo.tbl_post.Id, dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_name FROM dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id";
            SqlDataAdapter sda = new SqlDataAdapter(query, conn);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            lstNews.DataSource = dt;
            lstNews.DataBind();
        }
    }

请参阅参考here

另请参阅ALL NEWS

的列表视图代码
  <div class="Newsdivalign">
                <asp:ListView ID="lstNews" runat="server" OnPagePropertiesChanging="lstNews_PagePropertiesChanging">
                    <LayoutTemplate>
                        <asp:PlaceHolder ID="itemPlaceHolder" runat="server"></asp:PlaceHolder>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <div class="Newsdiv">
                            <p class="Newspara"><a id="a1" runat="server" href='<%# string.Format("#{0}", Eval("Id")) %>' class="modal-popup"><%# Eval("title") %></a></p>
                            <p class="NewsDate">
                                News Posted:
                                <asp:Literal ID="Literal1" runat="server" Text='<%# string.Format("{0:MMM dd, yyyy - hh:mm:ss tt}", Eval("dateforPost")) %>'></asp:Literal>
                                &nbsp;&nbsp;&nbsp;<span class="label"><%# Eval("ngo_name") %></span></p>
                            <p class="NewsDate1"><a href='<%# Eval("title") %>'>Click here</a> to know more </p>

                        </div>


                        <div id='<%# Eval("Id") %>' class="popup">
                            <div class="popup-container">
                                <div class="popup-content">
                                    <div class="popup-close js-popup-close modal-close">X</div>
                                    <div>
                                        <p class="popup-para"><%# Eval("title") %></p>
                                    </div>
                                    <div style="padding: 7px;">
                                        <p class="NewsDate">
                                            News Posted:                                   
                                            <asp:Literal ID="Literal2" runat="server" Text='<%# string.Format("{0:MMM dd, yyyy - hh:mm:ss tt}", Eval("dateforPost")) %>'></asp:Literal>
                                        </p>
                                        <p class="SStorypara">
                                            <%# Eval("description") %>
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </ItemTemplate>
                </asp:ListView>
                <div class="pagination clearfix">
                    <asp:DataPager ID="dpNews" runat="server" PagedControlID="lstNews" PageSize="10">
                        <Fields>
                            <asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="false" ShowPreviousPageButton="true"
                                ShowNextPageButton="false" />
                            <asp:NumericPagerField ButtonType="Link" />
                            <asp:NextPreviousPagerField ButtonType="Link" ShowNextPageButton="true" ShowLastPageButton="false" ShowPreviousPageButton="false" />
                        </Fields>
                    </asp:DataPager>
                </div>

                <%--<div id="testMsg" class="popup">
                    <div class="popup-container">
                        <div class="popup-content">
                            <div class="popup-close js-popup-close modal-close">X</div>
                            <div>
                                <p class="popup-para">Recognition statement</p>
                            </div>
                            <div style="padding: 7px;">
                                <p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST</p>
                                <p class="SStorypara">
                                    Lorem Ipsum is simply dummy text of the printing and typesetting industry.
                                </p>
                            </div>
                        </div>
                    </div>
                </div>--%>



                <%--<div id="testMsg" class="popup">
                    <div class="popup-container">
                        <div class="popup-content">
                            <div class="popup-close js-popup-close modal-close">X</div>
                            <div>
                                <p class="popup-para">Recognition statement</p>
                            </div>
                            <div style="padding: 7px;">
                                <p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST</p>
                                <p class="SStorypara">
                                    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
                                    the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley
                                    of type and scrambled it to make a type specimen book. It has survived not only five centuries, but
                                    also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in
                                    the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more
                                    recently with desktop publishing software like Aldus PageMaker including versions of Lorem
                                    Ipsum.
                                </p>
                                <p class="SStorypara">
                                    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
                                    the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley
                                    of type and scrambled it to make a type specimen book. It has survived not only five centuries, but
                                    also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in
                                    the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more
                                    recently with desktop publishing software like Aldus PageMaker including versions of Lorem
                                    Ipsum.
                                </p>
                                <p class="SStorypara">
                                    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
                                    the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley
                                    of type and scrambled it to make a type specimen book. It has survived not only five centuries, but
                                    also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in
                                    the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more
                                    recently with desktop publishing software like Aldus PageMaker including versions of Lorem
                                    Ipsum.
                                </p>
                                <p class="SStorypara">
                                    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
                                    the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley
                                    of type and scrambled it to make a type specimen book. It has survived not only five centuries, but
                                    also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in
                                    the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more
                                    recently with desktop publishing software like Aldus PageMaker including versions of Lorem
                                    Ipsum.
                                </p>
                            </div>

                        </div>
                    </div>
                </div>--%>

                <%--  <div class="Newsdiv">
                    <p class="Newspara"><a href="#testMsg" class="modal-popup">Recognition statement</a></p>
                    <p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span>&nbsp;<span class="label">NGO1</span> </p>
                    <p class="NewsDate1"><a href="#">Click here</a> to know more</p>
                </div>--%>

                <%--<div class="pagination clearfix">
                    <a href="#">First</a>
                    &nbsp;<a href="#">«</a>

                    <a href="#">1</a>
                    <strong>2</strong>
                    <a href="#">3</a>

                    <a href="#">»</a>
                    &nbsp;<a href="#">Last</a>
                </div>--%>
            </div>

请帮忙

0 个答案:

没有答案