We are providing Quality Education for C Language, C++ Language, C# Language ,Asp.net, Asp.net MVC with All framework as like MVC2 MVC3 MVC4 MVC5 MVC6 and Also we are providing Many Post mvc With Entity and Link Framework
Tuesday, 20 October 2015
Saturday, 3 October 2015
Asp.Net Page life-cycle event
Asp. Net Page Life Cycle events
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="pagelifecycle.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</div>
</form>
</body>
</html>
ASP.Net Grid View Tutorial
Insert Update Delete Using grid View :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
namespace gridviewinserupdatedel
{
public class mydblayer
{
public int empid { get; set; }
public string empname { get; set; }
public string gender { get; set; }
public string empphoto { get; set; }
}
public class empdataaccesslayer
{
public static List<mydblayer> getallemployee()
{
List<mydblayer> listemp = new List<mydblayer>();
string cs = ConfigurationManager.ConnectionStrings["iuConnectionString"].ToString();
SqlConnection cn = new SqlConnection(cs);
SqlCommand cmd = new SqlCommand("select * from employeedt",cn);
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
mydblayer employeedata = new mydblayer();
employeedata.empid = Convert.ToInt32(dr[0]);
employeedata.empname = dr[1].ToString();
employeedata.gender = dr[2].ToString();
employeedata.empphoto = dr[3].ToString();
listemp.Add(employeedata);
}
cn.Close();
return listemp;
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="gridviewclassWebForm1.aspx.cs" Inherits="gridviewinserupdatedel.gridviewclassWebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="empid" HeaderText="Employee Id" />
<asp:BoundField DataField="empname" HeaderText="Employee Name" />
<asp:BoundField DataField="gender" HeaderText="Employee Gender" />
<asp:TemplateField HeaderText="Employee Image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Bind("empphoto") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource= empdataaccesslayer.getallemployee();
GridView1.DataBind();
}
Subscribe to:
Posts (Atom)