Answer:
Table Name: Employees
Field | Data Type |
---|---|
DeptId | int |
DeptName | varchar |
EmpName | varchar |
Salary | decimal |
Sample SQL Query to Create the Table:
CREATE TABLE Employees (
DeptId INT,
DeptName VARCHAR(100),
EmpName VARCHAR(100),
Salary DECIMAL(10, 2)
);
Sample Data:
INSERT INTO Employees (DeptId, DeptName, EmpName, Salary) VALUES (1, 'HR', 'John Doe', 50000),
(2, 'IT', 'Jane Smith', 60000),
(3, 'Finance', 'Robert Brown', 70000);
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EmployeeApp._Default" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Employee List</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Employee List</h2>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True"
DataKeyNames="DeptId" Width="50%" CssClass="gridview-style">
</asp:GridView>
</div>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Web.UI;
namespace EmployeeApp
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Bind the GridView when the page loads
if (!IsPostBack)
{
GridView1.DataSource = SqlDataSource1;
GridView1.DataBind();
}
}
}
}