Possible Duplicate:
Converting Enumerable.Range to a List of Strings
In ASP.NET how do I populate a drop down list and also include text for the default selected state?
For eg.
A drop down will contain: Enter day, 1, 2, 3, 4, 5
ddlDayDropDown.DataSource = Enumerable.Range(1开发者_如何学Go, 31).ToList();
ddlDayDropDown.DataBind();
I can't add a "string" here.
Try ddlDayDropDown.Items.Insert(0, new ListItem("Enter day"));
ddlDayDropDown.DataSource = new string[] { "Enter day" }
.Concat(Enumerable.Range(1, 31).Select(n => n.ToString()));
ddlDayDropDown.DataBind();
精彩评论