Foreground HTML code:
<%@ page language= "C #" autoeventwireup= "true" codefile= "Main.aspx.cs" inherits= "Main"%><! DOCTYPE html> Background C # code:
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;public partial class main:system.web.ui.page{protected void Page_Load (object sender, Event Args e) {if (session["UID"]! = null) {if (! IsPostBack) {Testdatacontext context = new Testdatacontext (); Specifies the data source Repeater1.datasource = context. Info; Repeater1.databind (); }} else {Response.Redirect ("denglu.aspx"); }}//Gender function point with function to display male/female public string Showsex () {return Convert.toboolean (Eval ("Sex"))? "Male": "Female"; public string shownation () {Testdatacontext context = new Testdatacontext (); The Nation code for each item is a string type that is placed in code with string code = Eval ("Nation"). ToString (); The code checks the nation table as long as his name returns directly to the return context. Nation.where (p = p.cOde = = code). First (). Name; The public string Showbirthday () {///BIRTHDA This column returns a DateTime type return Convert.todatetime (Eval ("Birthday") ). ToString ("yyyy mm month DD day"); } protected void Button2_Click (object sender, EventArgs e) {///combination query//The first step takes all the data in a collection containing TestD Atacontext context = new Testdatacontext (); list<info> list = Context.Info.ToList (); The second step takes the first and second query conditions of string code = Txtcode.text; if (Code! = ") {//From the list collection, the code list = List of code equals input is filtered out. Where (p = = P.code = = Code). ToList (); } String name = txtName.Text; if (Name! = "") {list = list. Where (P = = P.name.contains (Name)). ToList (); }//To Reapeater do data source repeater1.datasource = list; Repeater1.databind (); } protected void button1_click (object sender, EventArgs e) {Response.Redirect ("insert.aspx"); }}
Page Display Picture:
WB Example Home page