I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
Introduction
The Generation operators help in creating a new sequence of values. The Generation operators are DefaultlfEmpty, Empty, Range, and Repeat. The DefaultlfEmpty clause replaces an empty collection with a default single collection. The Empty clause refers to an empty collection. The Range clause generates a collection that contains a sequence of numbers. The Repeat clause generates a collection that contains at least one repeated value.The syntax of Range clause is:
For C#
public static IEnumerable<int> Range( int start, int count);
The Range clause throws an ArgumentOutOfRangeException exception if the count is less than 0, or if the start + or count -1 parameters are larger than the maximum value.
The syntax of the Empty clause is:
For C#
public static IEnumerable<T> Empty<T>();
The Empty clause caches a single empty sequence of the given type.
Lets take an simple example
<form id="form1" runat="server"><div>
<asp:ListBox ID="ListBox1" runat="server" Height="254px" Width="153px">
</asp:ListBox>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="odd and even " />
</div>
</form>
Code Behind
protected void Button1_Click(object sender, EventArgs e)
{
var num = from n in Enumerable.Range(1, 20)
select new { Number = n, oddevennumber = n % 2 == 1 ? "odd" : "even" };
foreach (var item in num)
{
ListBox1.Items.Add("The number is " + item.Number + item.oddevennumber);
}
}
Code Generate the following output
Comments
Post a Comment