Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 单个aspx页面上的两个列表视图_Asp.net_Listview - Fatal编程技术网

Asp.net 单个aspx页面上的两个列表视图

Asp.net 单个aspx页面上的两个列表视图,asp.net,listview,Asp.net,Listview,我在aps.net页面上有两个asp.net列表视图,分别为1级和2级。我很难从2级访问1级的数据项。我需要对ListView和颜色代码中的项目进行比较 是否可以从同一页面上的另一个listview访问一个listview的数据项 代码如下: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head>

我在aps.net页面上有两个asp.net列表视图,分别为1级和2级。我很难从2级访问1级的数据项。我需要对ListView和颜色代码中的项目进行比较

是否可以从同一页面上的另一个listview访问一个listview的数据项

代码如下:

    <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>


</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ListView ID="lst1" runat="server">
            <ItemTemplate>
                <table class="tblClass" width="95%" border="0" style="margin: auto; font-size: 13px;
                    height: 150px;">
                    <br />
                    <tr>
                        <td>
                            Account#:
                        </td>
                        <td align="right">
                            <b>
                                <%#Eval("ID")%></b>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Email:
                        </td>
                        <td  align="right">
                            <%#Eval("DefaultEmail")%>
                            <input type="radio" id="rad1" <%#(String.IsNullOrEmpty(Eval("DefaultEmail").ToString()) ? "disabled" : " ")%>
                                name="radEmail" value="<%#Eval("DefaultEmail") %>" />
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:ListView>
    </div>
    <div>
        <asp:ListView ID="lst2" runat="server">
            <ItemTemplate>
                <table class="tblClass" width="95%" border="0" style="margin: auto; font-size: 13px;
                    height: 150px;">
                    <br />
                    <tr>
                        <td>
                            Account#:
                        </td>
                        <td align="right">
                            <b>
                                <%#Eval("ID")%></b>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Email:
                        </td>
                        <td  align="right">
                            <%#Eval("DefaultEmail")%>
                            <input type="radio" id="rad2" <%#(String.IsNullOrEmpty(Eval("DefaultEmail").ToString()) ? "disabled" : " ")%>
                                name="radEmail" value="<%#Eval("DefaultEmail") %>" />
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:ListView>
    </div>
    </form>
</body>
</html>

我想使用EVAL访问lst1中lst2的电子邮件项目……这样,如果两个值不同,我可以对tr元素进行颜色编码。

在将它们绑定到listiviews之前,如何在集合中解决此问题

大概是这样的:

在绑定到listview1的类1上添加其他属性,例如:bool EmailExists 遍历绑定到listview1的集合,并在绑定到listView2的第二个集合中搜索电子邮件。如果找到匹配项,请将EmailExists属性设置为True。 用于根据EmailExists的值为tr元素适当着色
如果您发布了当前尝试执行此操作的方式,可能会有所帮助。添加了代码。谢谢。@user1967701数据源在哪里?在第\u页的代码隐藏中进行数据绑定。我遇到了一个问题:ListView1有一个数据绑定选择ID,来自TableA的电子邮件ID=1,Listview2有一个数据绑定选择ID,来自TableA的电子邮件ID=2。我还能照你的建议做吗?谢谢。嗨,我想你可以。我想在将数据绑定到LostView之前,先将查询结果填充到对象列表中。谢谢。我能够使用一个列表视图,并重新编写查询,将两行转换为一行。