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 }); }
Use HasRows property of SqlDataReader class
Gets a value that indicates whether the SqlDataReader contains one or more rows (msdn.microsoft.com)
Step-1 : Create a database table with empty data
Step-2 : Check data in database using HasRows property of SqlDataReader class
Step-3 : Write code on page_load method
using System;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
public partial class duplicatevalue : System.Web.UI.Page
{
SqlDataReader rd;
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection())
{
con.ConnectionString =ConfigurationManager .ConnectionStrings ["ConnectionString"].ToString ();
con.Open();
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "checkdata";
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
rd = cmd.ExecuteReader();
if (rd.HasRows)
{
result.Text="Row Exisit"; //here result is the id of the label control
}
else
{
result.Text = "no row found";
}
}
}
}
OutPut Screen
Gets a value that indicates whether the SqlDataReader contains one or more rows (msdn.microsoft.com)
Step-1 : Create a database table with empty data
Step-2 : Check data in database using HasRows property of SqlDataReader class
Step-3 : Write code on page_load method
using System;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
public partial class duplicatevalue : System.Web.UI.Page
{
SqlDataReader rd;
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection())
{
con.ConnectionString =ConfigurationManager .ConnectionStrings ["ConnectionString"].ToString ();
con.Open();
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "checkdata";
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
rd = cmd.ExecuteReader();
if (rd.HasRows)
{
result.Text="Row Exisit"; //here result is the id of the label control
}
else
{
result.Text = "no row found";
}
}
}
}
OutPut Screen
Comments
Post a Comment