开发者

asp.net dropdown datasource [duplicate]

This question already has answers here: Closed 11 years ago.

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜