Now copy following code and enjoy.
CODE : Friend-List.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Friend-List.aspx.cs" Inherits="Friend_List" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Friend List</h1>
<a href="Default.aspx">New Friend</a>
<asp:GridView ID="gvFriend" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Sr.No">
<ItemTemplate>
<%# Container.DataItemIndex + 1%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FriendName" HeaderText="Friend Name" />
<asp:BoundField DataField="Mobile" HeaderText="Mobile" />
<asp:TemplateField HeaderText ="Edit" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<a href='edit-friend.aspx?frndid=<%#Eval("FriendID")%>'>Edit</a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText ="Delete" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<a href='delete-friend.aspx?frndid=<%#Eval("FriendID")%>'>Delete</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
CODE -- Friend-List.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Friend_List : System.Web.UI.Page
{
FriendDataClassesDataContext db = new FriendDataClassesDataContext();
protected void Page_Load(object sender, EventArgs e)
{
var FrndList = (from a in db.dbFriends select a).ToList();
gvFriend.DataSource = FrndList;
gvFriend.DataBind();
}
}
I provide Asp.Net WebForm, MVC, Core training. You can me contact for further guidance.
Mobile : 9869166077
Email : manojbkalla@hotmail.com // mr.manojbkalla@gmail.com
ReactJs training, Angular Training in Malad, Kandivali, Borivali, Andheri, Bandra, Juhu, Marine Line, Kalbadevi, Virar, Vasai, Dadar, Mumbai.
Provide all BCA, MCA Training online or offline.
YCMOU university courses.
No comments:
Post a Comment