C#中的datalist天搜索问题

编程入门 行业动态 更新时间:2024-10-25 07:21:27
本文介绍了C#中的datalist天搜索问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 实际上我在搜索引擎的位置,技能,功能区和行业中都有4个搜索栏,这个搜索引出了数据列表,其中包含一些详细信息约会。 现在我必须从该数据列表中下载60天和30天的新数据过滤器。 所以我用这个代码

Hi all, Actually I have 4 search bar in search engine location, skills, functional area and industry and this search leads to datalist with some detail with posted date. now i have to dropdown with 60 days and 30days fresh data filter from that datalist. so i used this code

if (ddfreshness.SelectedItem.ToString() == "Any") { BindDataList(); } else if (ddfreshness.SelectedItem.ToString() == "30 Days") { foreach (DataListItem dli in DataList1.Items) { //fetching posted date from datalist Label l45 = (Label)dli.FindControl("lblprloc2"); DateTime now = DateTime.Today; TimeSpan ts = now - Convert.ToDateTime(l45.Text); // Difference in days. int differenceInDays = ts.Days; string date = Convert.ToString(differenceInDays) + " Days"; if (differenceInDays <= 30) { //bind fuction for the data to same datalist BindDataList(); } } }

Collection was modified; enumeration operation may not execute

请帮我这个代码。

plz help me for this code.

推荐答案

你不能重新绑定当天数据列表中项目列表中的foreach循环中的列表! 对于与foreach一起使用的任何集合,您不能这样做 - 它会更改项目的数量或顺序循环试图迭代。 在循环外移动BindDataList调用。 You cannot rebind the day a list within a foreach loop on the list of items in the datalist! You can't do that with any collection that is being used with a foreach - it changes the number or order of the items that the loop is trying to iterate through. Move the BindDataList call outside the loop.

更多推荐

C#中的datalist天搜索问题

本文发布于:2023-11-09 23:05:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573682.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:datalist

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!