显示ListView控件的标签结果

时间:2015-11-13 00:00:56

标签: c# asp.net .net listview listviewitem

我有一个产品搜索文本框,其中包含一个要在母版页上提交的按钮。当用户单击“提交”时,文本框中的值将存储在会话[“搜索”]中,页面将重定向到search.aspx。在search.aspx上,listview将搜索产品并显示它。一切都有效,除非我决定添加这个

select {
    -webkit-appearance: none;
    -moz-appearance: none;
}

现在,当我搜索产品时,lblSearch.Text =“抱歉找不到搜索”。始终显示。

这是我的Search.aspx背后的代码:

if (ListView1.Items.Count == 0)
            {
                lblSearch.Text = "Sorry search is not found.";
            }

我认为ListView1.Items.Count出了问题。另外,我使用的是SqlDataSource。有任何想法吗?提前谢谢。

以下是Search.aspx的标记

protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Search"] != null)
        {
            lblSearch.Text = Session["Search"].ToString();

            if (ListView1.Items.Count == 0)
            {
                lblSearch.Text = "Sorry search is not found.";
            }
        }
        else
        {
            lblSearch.Text = "";
        }
    }

0 个答案:

没有答案
相关问题