you are getting error becuase you have declared ss variable in foreach loop and using ss variable out of function scope
athelli_reddy
foreach(DateTime t in vv) {
String ss
=GetPrettyDate(t);
newList.Add(ss);
}
this.ListView1.DataSource= newList; //HERE I WANT TO BIND DATA TO DateDisplayLabel like below
l.Text= ss;---But I am getting an error message. this.ListView1.DataBind();
just declare string ss variable before foreach loop , and do this
String ss = "";
foreach (DateTime t in vv)
{
ss = GetPrettyDate(t);
newList.Add(ss);
}
newbiefreak
Member
468 Points
214 Posts
Re: Binding modified data source to listview label
Apr 27, 2012 01:47 PM|LINK
you are getting error becuase you have declared ss variable in foreach loop and using ss variable out of function scope
just declare string ss variable before foreach loop , and do this
String ss = ""; foreach (DateTime t in vv) { ss = GetPrettyDate(t); newList.Add(ss); }i hope this helps you