<%@ Page Language="C#" %> <!DOCTYPE html> <script runat="server"> protected void btnUpload_Click(object sender, EventArgs e) { // Check whether FileUpload has any files if (FileUpload1.HasFiles) { // Iterate over files foreach (HttpPostedFile file in FileUpload1.PostedFiles) { file.SaveAs(Server.MapPath("~/files/") + file.FileName); } lblMsg.Text = "Uploaded " + FileUpload1.PostedFiles.Count + " files!"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> Select Files to upload : <asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true"/> <p /> <asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" /> <p /> <asp:Label ID="lblMsg" runat="server" Text=""></asp:Label> </form> </body> </html>
public class Employee { public int Id { get;set;} public string Name { get;set;} public string JobTitle { get;set;} public int Salary { get;set; } }
<%@ Page Language="C#" %> <!DOCTYPE html> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { List<Employee> employees = new List<Employee> { new Employee { Id = 1, Name = "Ronaldo", JobTitle = "Programmer", Salary = 50000}, new Employee { Id = 2, Name = "Alanso", JobTitle = "Tester", Salary = 30000}, new Employee { Id = 3, Name = "Ramos", JobTitle = "DBA", Salary = 70000} }; dataListEmployees.DataSource = employees; dataListEmployees.DataBind(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <h2>List Of Employees</h2> <asp:DataList ID="dataListEmployees" runat="server" ItemType="Employee"> <ItemTemplate> <b><%# Item.Id %> </b> <br /> <%# Item.Name%> <br /> <%# Item.JobTitle %> <br /> <%# Item.Salary %> <p /> </ItemTemplate> </asp:DataList> </form> </body> </html>
<asp:TemplateField HeaderText="Address"> <ItemTemplate><%#: Item.Address %></ItemTemplate> </asp:TemplateField>
<%@ Page Language="C#" %> <!DOCTYPE html> <script runat="server"> public List<Employee> GetEmployees() { List<Employee> employees = new List<Employee> { new Employee { Id = 1, Name = "Ronaldo", JobTitle = "Programmer", Salary = 50000}, new Employee { Id = 2, Name = "Alanso", JobTitle = "Tester", Salary = 30000}, new Employee { Id = 3, Name = "Ramos", JobTitle = "DBA", Salary = 70000} }; return employees; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <h2>List Of Employees</h2> <asp:GridView ID="gvEmployees" runat="server" SelectMethod="GetEmployees"> </asp:GridView> </form> </body> </html>
<%@ Page Language="C#" %> <!DOCTYPE html> <script runat="server"> public List<Employee> GetEmployees() { List<Employee> employees = new List<Employee> { new Employee { Id = 1, Name = "Ronaldo", JobTitle = "Programmer", Salary = 50000}, new Employee { Id = 2, Name = "Alanso", JobTitle = "Tester", Salary = 30000}, new Employee { Id = 3, Name = "Ramos", JobTitle = "DBA", Salary = 70000} }; return employees; } public List<Employee> GetSelectedEmployees( [System.Web.ModelBinding.Control ("txtSalary")] string salary ) { if (Page.IsPostBack) { var employees = GetEmployees(); return employees.FindAll(e => e.Salary > Int32.Parse(salary)); } else return null; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <h2>List Of Employees</h2> Minmum Salary : <asp:TextBox ID="txtSalary" runat="server"></asp:TextBox> <asp:Button ID="btnSubmit" runat="server" Text="Submit" /> <p /> <asp:GridView ID="gvEmployees" runat="server" SelectMethod="GetSelectedEmployees"> </asp:GridView> </form> </body> </html>