-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndex.aspx
54 lines (49 loc) · 2.96 KB
/
Index.aspx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<%@ Page Language="C#" MasterPageFile="~/MasterPage.Master" %>
<%@ Import Namespace="EmpManagement.App_Code.Services" %>
<script runat="server">
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
if (!e.NewValues.Contains("Department.Id"))
return;
var id = Convert.ToInt32(e.NewValues["Department.Id"]);
var dptId = DepartmentService.GetDepartmentById(id);
e.NewValues.Remove("Department.Id");
e.OldValues.Remove("Department.Id");
e.NewValues.Add("Department", dptId);
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FormBodyContent" runat="server">
<asp:GridView ID="GridView1" OnRowUpdating="GridView1_RowUpdating"
DataKeyNames="Id" runat="server" AutoGenerateColumns="False"
DataSourceID="ObjectDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Role" HeaderText="Role" SortExpression="Role" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="Joined" HeaderText="Joined" SortExpression="Joined" DataFormatString="{0:dd-MMMM-yyyy}" />
<asp:TemplateField ConvertEmptyStringToNull="False" HeaderText="Department" SortExpression="Department">
<EditItemTemplate>
<asp:DropDownList ID="DepartmentDropdown" runat="server" DataSourceID="ObjectDataSource2"
DataTextField="Name" DataValueField="Id" SelectedValue='<%# Bind("Department.Id") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<%# Eval("Department.Name") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="Create.aspx">New</asp:HyperLink>
<br />
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DataObjectTypeName="EmpManagement.App_Code.Models.Employee" DeleteMethod="Delete"
InsertMethod="Insert" SelectMethod="GetAll"
TypeName="EmpManagement.App_Code.Services.EmployeeService" UpdateMethod="Update">
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
SelectMethod="GetAll" TypeName="EmpManagement.App_Code.Services.DepartmentService"></asp:ObjectDataSource>
</asp:Content>