we can make dropdown list in asp.net component with below syntax
<asp:DropDownList ID="test" runat="server">
<asp:ListItem Text="1" Value="1"></asp:ListItem>
</asp:DropDownList>
if we want our combo box contain 1 to 1000 , is there any way to populate it with foreach loop , rather than manually add 1000 item to it ?
Here's some pseudocode:
You will have to find out exactly how to create the ListItem and populate it with a value.
Sure, in your code-behind:
Very basic code...
How about just binding the dropdown list directly to a collection of numbers?
Yes, you can add
ListItems
programmatically:ListItemCollection.Add
You could also use this linq query and use it as DataSource: