Webfrom Generate serial number combination query repeater the use of radio and check control JS combat application

Source: Internet
Author: User


Default.aspx Web Interface


<%@ page language= "C #" autoeventwireup= "true" codefile= "Default.aspx.cs" inherits= "_default"%>

<! DOCTYPE html>

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title></title>
<body>
<form id= "Form1" runat= "Server" >
<div>

<asp:label id= "Label1" runat= "Server" text= "serial number Generation" font-bold= "True" font-size= "30px" ></asp:Label>

<br/>
Code: <asp:textbox id= "TextBox1" runat= "Server" ></asp:TextBox>
<asp:button id= "Button1" runat= "Server" onclick= "Button1_Click" text= "Generate serial number"/>
<br/>
Name: <asp:textbox id= "TextBox2" runat= "Server" ></asp:TextBox>
<br/>
Gender: <asp:textbox id= "TextBox3" runat= "Server" ></asp:TextBox>
<br/>
National:
<asp:textbox id= "TextBox4" runat= "Server" ></asp:TextBox>
&nbsp;<br/>
Birthday:
<asp:textbox id= "TEXTBOX5" runat= "Server" ></asp:TextBox>
<br/>
<asp:button id= "Button2" runat= "Server" text= "commit"/>
<br/>
<br/>

</div>
</form>
</body>

Defaule.aspx.cs C # interface

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;

public partial class _default:system.web.ui.page
{
Private Mydbdatacontext _context = new Mydbdatacontext ();
protected void Page_Load (object sender, EventArgs e)
{


}
protected void Button1_Click (object sender, EventArgs e)
{
string prefix = "p" + DateTime.Now.ToString ("YyyyMMdd");
1 Check the day's largest serial number
int maxflow = 0;
var query = _context.info.where (p=>p.code.startswith (prefix));
if (query. Count () > 0)
{
query = query. OrderByDescending (P=>p.code);//ORDER by serial number
String maxcode = query. First (). code;//Get maximum serial number
Maxflow =convert.toint32 (maxcode.substring (9));
}

Combination query the latest serial number
String flowcode = prefix + (maxflow + 1). ToString ("000");
Show in text box
TextBox1.Text = Flowcode;
}
}

*********************************************************************************************

Combination Query

*********************************************************************************************

Default.aspx Web Interface

<%@ page language= "C #" autoeventwireup= "true" codefile= "Default2.aspx.cs" inherits= "DEFAULT2"%>

<! DOCTYPE html>

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title></title>
<body>
<form id= "Form1" runat= "Server" >
<div>

Car name: <asp:textbox id= "txtname" runat= "Server" ></asp:TextBox>
&nbsp; Series: <asp:dropdownlist id= "Ddlbrand" runat= "Server" appenddatabounditems= "True" >
<asp:listitem value= "-1" >== Please select ==</asp:listitem>
</asp:DropDownList>
&nbsp; Fuel consumption: <asp:textbox id= "Txtoil" runat= "Server" ></asp:TextBox>
<asp:button id= "Button1" runat= "server" text= "query" onclick= "Button1_Click"/>
<br/>
<asp:repeater id= "Repeater1" runat= "Server" >
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<%# Eval ("Name")%>
<font color= "Red" ><%# Eval ("Brand")%></font>
<font color= "Blue" ><%# Eval ("oil")%></font>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>

</div>
</form>
</body>

Defaule.aspx.cs C # interface

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;

public partial class Default2:System.Web.UI.Page
{
Private Mydbdatacontext _context = new Mydbdatacontext ();
private void Fillbrand ()
{
var query = _context.brand;

Ddlbrand.datasource = query;
Ddlbrand.datatextfield = "Brand_Name";
Ddlbrand.datavaluefield = "Brand_Code";
Ddlbrand.databind ();
}
protected void Page_Load (object sender, EventArgs e)
{
if (! IsPostBack)
{
Fillbrand ();
}
}
Core code:
protected void Button1_Click (object sender, EventArgs e)
{

var query1 = _context.car.asqueryable (); According to the name of the default should be the complete
var query2 = _context.car.asqueryable ();//based on series check
var query3 = _context.car.asqueryable ();//based on fuel consumption check

Complete the above three query conditions according to the input box fill situation
if (TxtName.Text.Trim (). Length > 0)
{
Query1 = Query1. Where (p = p.name.contains (txtName.Text));
}
if (ddlbrand.selectedvalue! = "-1")
{
Query2 = Query2. Where (p = = P.brand = = Ddlbrand.selectedvalue);
}
if (TxtOil.Text.Trim (). Length > 0)
{
Query3 = Query3. Where (p = = P.oil = = Convert.todecimal (txtoil.text));
}

Three query conditions are logical relationships that can be implemented using the intersection of collection operations
var query = Query1. Intersect (Query2). Intersect (Query3);

Binding display
Repeater1.datasource = query;
Repeater1.databind ();

}
}

*********************************************************************************************

The use of single and check controls in Repeater JS Combat application

*********************************************************************************************

Default.aspx Web Interface

<%@ page language= "C #" autoeventwireup= "true" codefile= "Default3.aspx.cs" inherits= "DEFAULT3"%>

<! DOCTYPE html>

<meta http-equiv= " Content-type "content=" text/html; Charset=utf-8 "/>
<title></title>
<script language=" javascript ";
function Checkall ( Ckall) {
//Find all the check boxes to the left of each item.
var cks = document.getelementsbyname ("ck");
//Iterate through each check box to set the selected state of each check box to be the same as Chkall
for (var i = 0; i < cks.length; i++) {
cks[i].checked = ckall.checked;}
}
function Setcheckall () {
///idea: Iterate through the check boxes of all items to determine whether to select all. If it is all selected, set the Ckall to selected, or leave it unchecked.
//1. Locate the check box for all items.
var cks = document.getelementsbyname ("ck");
//2. Traverse each check box to record whether it is selected all.
var selectedall = true;
for (var i = 0; i < cks.length; i++) {
Selectedall = Selectedall && cks[i].checked;
}
//3. Determine the selected state of Ckall
var ckall = document.getElementById ("Ckall") depending on whether the state is selected as a whole,
ckall.checked = Selectedall;
}
Function Dodelete () {
//1. Find the check box for all items.
var cks = document.getelementsbyname ("ck");

2. Determine if there are any selected items
var SelectedItem = false;
for (var i = 0; i < cks.length; i++) {
SelectedItem = cks[i].checked | | SelectedItem;
}
3. Give different dialog box prompts depending on the selected item
if (SelectedItem = = False) {
Alert ("Please select the item to delete");
return false;
}
else {
var del = confirm ("Confirm that you want to delete the selected item?") ");
Return del;
}
}
</script>
<body>
<form id= "Form1" runat= "Server" >
<div>

<asp:repeater id= "Repeater1" runat= "Server" >
<HeaderTemplate>
<table width= "100%" border= "0" cellspacing= "5" >
<tr>
<td>
<input id= "Ckall" name= "Ckall" type= "checkbox" onclick= "Checkall (This)"/>
</td>
<td> name </td>
<td> Series </td>
<td> Manufacturers </td>
<td> Price </td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<input id= "ck_<%# eval (" code ")%>" name= "ck" type= "checkbox" Value= "<%# Eval (" code ")%>" onclick= " Setcheckall () "/>
</td>
<td><%# Eval ("Name")%></td>
<td><%# Eval ("brandname")%></td>
<td><%# Eval ("ProdName")%></td>
<td><%# Eval ("Price")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

</div>
<asp:button id= "Button1" runat= "Server" onclientclick= "return Dodelete ()" onclick= "Button1_Click" text= "delete"/>
<br/>
<asp:label id= "Label1" runat= "Server" text= "Label" ></asp:Label>
<asp:literal id= "Literal1" runat= "Server" ></asp:Literal>
</form>
</body>

Defaule.aspx.cs C # interface

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;

public partial class Default3:System.Web.UI.Page
{
Private Mydbdatacontext _context = new Mydbdatacontext ();
protected void Page_Load (object sender, EventArgs e)
{
if (! IsPostBack)
{
Show ();
}
}

private void Show ()
{
var query = _context.car;

Repeater1.datasource = query;
Repeater1.databind ();
}
protected void Button1_Click (object sender, EventArgs e)
{
if (request["CK"]! = NULL)
{
Gets the primary key value of the selected item
string s = request["CK"]. ToString (); The value of the selected item, used, separated.
String[] keys = s.split (', '); Splits the string above to form an array of primary key values.
Delete data based on the primary key value above
foreach (string key in keys)
{
var query = _context.car.where (P=>p.code = = key);
if (query. Count () > 0)
{
Car data = query. First ();
_context.car.deleteonsubmit (data);
_context.submitchanges ();
}
}
Refresh Display
Show ();
Literal1.text = "<script language= ' JavaScript ' >alert (' delete succeeded ') </script>";
}
}
}

Webfrom Generate serial number combination query repeater the use of radio and check control JS combat application

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.