LIstView数据隐藏基于sql查询 [英] LIstView data hiding based on sql query

查看:56
本文介绍了LIstView数据隐藏基于sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

i有一些数据列表视图



它有一个标签返回true,false或pending



我想要的是,如果它返回true

它应该启用radbutton1,它在listview里面



如果它返回false

它应该启用radbutton2,它在listview里面



如果它返回待定

它应该使这两个单选按钮可见错误。



和listview中不同行的状态会有所不同,所以我的单选按钮重复其可见性对于不同的行也会有所不同。

任何人都可以解释......怎么做?



我的代码

Hello all,
i have listview with some data

it has one label which is returning either true, false or pending

what i want is, if it returns true
it should enable radbutton1 which is inside listview

if it returns false
it should enable radbutton2 which is inside listview

if it returns pending
it should make those two radio buttons visiblity false.

and status will be different for diffrent rows in my listview, so my radio buttons which are repeating its visiblity will also be different for different rows.
can anyone explain...how to do it?

My Code

<asp:ListView ID="ListView2" runat="server" OnPagePropertiesChanging="ListView1_PagePropertiesChanging" 

    onitemcommand="ListView1_ItemCommand">
    <alternatingitemtemplate>
        <p align="justify">
            <span style="color: #000000; text-align: center; width: 100%;">
                <asp:Label ID="DescriptionLabel2" runat="server" Text='<%# Eval("Message") %>' />
            </span>
            <asp:RadioButton ID="radYes" runat="server" Text="Yes" GroupName="Action" />
            <asp:RadioButton ID="radNo" runat="server" Text="No" GroupName="Action" />
        </p>
    </alternatingitemtemplate>
    <edititemtemplate>
        <p align="justify">
            <span style="color: #000000; text-align: center; width: 100%;">
               <asp:Label ID="DescriptionLabel2" runat="server" Text='<%# Eval("Message") %>' />
            </span>
            <asp:RadioButton ID="radYes" runat="server" Text="Yes" GroupName="Action" />
            <asp:RadioButton ID="radNo" runat="server" Text="No" GroupName="Action" />
        </p>
    </edititemtemplate>
    <emptydatatemplate>
        <span style="color: #FF0000; font-weight: bold;">Sorry! No Records found...</span>
    </emptydatatemplate>
    <insertitemtemplate>
        <p align="justify">
            <span style="color: #000000; text-align: center; width: 100%;">
               <asp:Label ID="DescriptionLabel2" runat="server" Text='<%# Eval("Message") %>' />
            </span>
            <asp:RadioButton ID="radYes" runat="server" Text="Yes" GroupName="Action" />
            <asp:RadioButton ID="radNo" runat="server" Text="No" GroupName="Action" />
        </p>
    </insertitemtemplate>
    <itemtemplate>
        <p align="justify">
            <span style="color: #000000; text-align: center; width: 100%;">
                <asp:Label ID="DescriptionLabel2" runat="server" Text='<%# Eval("Message") %>' />
            </span>
            <asp:RadioButton ID="radYes" runat="server" Text="Yes" GroupName="Action" />
            <asp:RadioButton ID="radNo" runat="server" Text="No" GroupName="Action" />
        </p>
    </itemtemplate>
    <SelectedItemTemplate>
        <p align="justify">
            <span style="color: #000000; text-align: center; width: 100%;">
                <asp:Label ID="DescriptionLabel2" runat="server" Text='<%# Eval("Message") %>' />
            </span>
            <asp:RadioButton ID="radYes" runat="server" Text="Yes" GroupName="Action" />
            <asp:RadioButton ID="radNo" runat="server" Text="No" GroupName="Action" />
        </p>
    </SelectedItemTemplate>
    <itemseparatortemplate>
        <hr />
    </itemseparatortemplate>
</asp:ListView>

推荐答案

您可以在listview的ItemDataBound事件中实现此目的。



http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.itemdatabound.aspx [<一个HREF =http://msdn.microsoft.com/en-us/library/sys tem.web.ui.webcontrols.listview.itemdatabound.aspxtarget =_ blanktitle =新窗口> ^ ]
You can achieve this in listview''s ItemDataBound event.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.itemdatabound.aspx[^]


这篇关于LIstView数据隐藏基于sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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