如何隐藏datalist ItemTemplate Panel [英] how can I hide the datalist ItemTemplate Panel

查看:101
本文介绍了如何隐藏datalist ItemTemplate Panel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:DataList ID="DataList1" runat="server" >
        <itemtemplate>
            <table>
                <tr>
                    <td>
                        School Name:
                        <asp:Label ID="lblName" runat="server" Text='<%# Bind("SchoolName") %>' align="center"> 
                    </td>
                </tr>
                <tr>
                    <td>
                        About School:
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("AboutSchool") %>' align="center"> 
                    </td>
                </tr>
                <tr>
                    <td>
                        Contact:
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("Contact") %>' align="center"> 
                    </td>
                </tr>
                <tr>
                    <td>
                        Address:
                        <asp:Label ID="lblAddress" runat="server" Text='<%# Bind("Address") %>'>
                    </td>
                </tr>
                <tr>
                    <td>
                        Website:
                        <asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Bind("Website") %>'>LinkButton
                    </td>
                </tr>
            </table>
            <asp:Panel ID="pnlEdit" runat="server" Visible="false">
                <asp:Button ID="btnEdit" runat="server" Text="Edit" >
                
                <asp:Button ID="btnDelete" runat="server" Text="Delete"  

                    OnClientClick="return confirm('Are you sure you want to delete selected records')">
        </itemtemplate>

推荐答案

因为你有一个数据库而你获取有关所有用户的信息以及与他们相关的信息,无论登录人员只是用户还是管理员,因此检索有关pageload事件的信息,并在此基础上启用或禁用您的面板。
As you have a database and you have information about all the users and info related to them whether the login person is simply a user or an Admin so retrieve that information on pageload event and on the basis of that just enable or disable your panel.


您需要使用 item.FindControl(controlId)技术来查找控件。



为了隐藏它,在 ItemDataBound 事件中写入逻辑。
You need to use the item.FindControl("controlId") technique to find a control.

For hiding it, write the logic inside the ItemDataBound event.


hi,

页面加载事件,默认情况下您可以隐藏它。当您检查用户角色(例如:管理员)时,您可以显示它。

on page load event,by default you can hide it. And when you are checking the User role (ex: Admin) then you can show it.


这篇关于如何隐藏datalist ItemTemplate Panel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆