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 }); }
I want to say that how to add English alphabets at run time in DropdownList. A intermediate programmer know that each char contain a ASCII value like 65 is a ASCII value of letter 'A'. Similarly again 66 to 90 is a ASCII value of Letter B to Z. So add a DropdownList in the design page also bind with Alphabet public property. Look like this:
Source page:
<asp:DropDownList ID="Letters" DataSource='<%# Alphabet %>' runat="server" />
Code Behind Page:
public partial class Bynamejobsearch : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataBind();
}
}
private List<char> _Alphabet;
protected List<char> Alphabet
{
get
{
if (_Alphabet == null)
{
_Alphabet = new List<char>();
for (int i = 65; i < 91; i++)
{
_Alphabet.Add(Convert.ToChar(i));
}
}
return _Alphabet;
}
}
}
In this program i have a list of type char. Use for loop which is start from 65 to 90. Add this char in the list one by one.
Source page:
<asp:DropDownList ID="Letters" DataSource='<%# Alphabet %>' runat="server" />
Code Behind Page:
public partial class Bynamejobsearch : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataBind();
}
}
private List<char> _Alphabet;
protected List<char> Alphabet
{
get
{
if (_Alphabet == null)
{
_Alphabet = new List<char>();
for (int i = 65; i < 91; i++)
{
_Alphabet.Add(Convert.ToChar(i));
}
}
return _Alphabet;
}
}
}
In this program i have a list of type char. Use for loop which is start from 65 to 90. Add this char in the list one by one.
Comments
Post a Comment