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 }); }
follow some steps for checking data into database
Step 1: Create table in database http://dotprogramming.blogspot.in/2013/06/how-to-make-database-table-in-visual.html
Step 2: Take a web form name as "duplicatevalue.aspx"
Step 3: Design a Webform
Step 1: Create table in database http://dotprogramming.blogspot.in/2013/06/how-to-make-database-table-in-visual.html
Step 2: Take a web form name as "duplicatevalue.aspx"
Step 3: Design a Webform
Step 4: Make Connection string in web.config file
Step-5 : Create procedure for retrieving data
CREATE PROCEDURE [dbo].[checkdata]
AS
SELECT * from [Table]
RETURN 0
Step 6: Double click on "Check Existing" Button and make code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
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)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
bool flag = true;
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();
while (rd.Read ())
{
if (rd["EmployeeId"].ToString().Equals(empid.Text))
{
flag = false;
break;
}
}
if (flag == false)
result.Text = "ALREADY EXISTS";
else
result.Text = "not existes";
}
}
}
}
Out put of the program
Comments
Post a Comment