Does not load when binded thro dataset values

Jan 17, 2014 at 12:19 PM
Edited Jan 17, 2014 at 12:42 PM
When I use your control with the given example from for loop, it works. But for some reason the below code doesn't. Please let me know the reason

Not Working code:
            DataSet ds = GetTheData("Jan 2014");
            DataTable dt = ds.Tables[0];

            var q = from a in dt.AsEnumerable()
                       where a.Field<string>("SomeColumn1") == "Jan 2014"
                       select a.Field<string>("SomeColumn2");

            var s = q.Distinct().ToList();
            var years = new string[s.Count];
            for (int i = 0; i < s.Count; i++)
                years[i] = s[i];

            DropDownCheckBoxes1.DataSource = years;
            DropDownCheckBoxes1.DataBind();
Working Code:
var t = new string[20];
var currentYear = DateTime.Now.Year;
for (int i = 0; i < t.Length; i++)
t[i] = "Test   " + i.ToString();

DropDownCheckBoxes1.DataSource = t;
DropDownCheckBoxes1.DataBind();
Jan 20, 2014 at 5:11 AM
I got to know what is wrong. the control DropDowncheckboxes uses Page.ClientScript and even I was using Page.ClientScript at GetTheData() function. This was causing issue. I commented out my Page.ClientScript and it started working.
Marked as answer by cdraghavendra on 1/19/2014 at 9:11 PM