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 }); }
Using the Resize method you can decrement size of an array. Resize method creates a new array with new specified size Also copy old array items into newly created. Let's take an simple example to remove last element. Take less than one size of original array size. Newly created array skip last element of original array size.
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Height="37px" onclick="Button1_Click"
Text="Vegetable" Width="100px" />
<div>
<asp:Label ID="Label1" runat="server" Text="Label" Width="100px" ForeColor="Black" BackColor="Yellow"></asp:Label>
</div>
</form>
{
string[] Vegtables = new string[]
{
"1.Tomato",
"2.Sweet-potato",
"3.Onion",
"4.Potato",
"5.Carrot",
"6.Locky",
"7.Brinjal"
};
Label1.Text = "Vegtables array...<br />";
foreach (string Vegtable in Vegtables)
{
Label1.Text += Vegtable + "<br />";
}
Array.Resize(ref Vegtables, Vegtables.Length - 1);
Label1.Text += "<br />Vegtables array [last element remove...<br />";
foreach (string Vegtable in Vegtables)
{
Label1.Text += Vegtable + "<br />";
}
}
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Height="37px" onclick="Button1_Click"
Text="Vegetable" Width="100px" />
<div>
<asp:Label ID="Label1" runat="server" Text="Label" Width="100px" ForeColor="Black" BackColor="Yellow"></asp:Label>
</div>
</form>
Business Logic code
protected void Button1_Click(object sender, EventArgs e){
string[] Vegtables = new string[]
{
"1.Tomato",
"2.Sweet-potato",
"3.Onion",
"4.Potato",
"5.Carrot",
"6.Locky",
"7.Brinjal"
};
Label1.Text = "Vegtables array...<br />";
foreach (string Vegtable in Vegtables)
{
Label1.Text += Vegtable + "<br />";
}
Array.Resize(ref Vegtables, Vegtables.Length - 1);
Label1.Text += "<br />Vegtables array [last element remove...<br />";
foreach (string Vegtable in Vegtables)
{
Label1.Text += Vegtable + "<br />";
}
}
Comments
Post a Comment