Jquery implements repeater refreshing batch deletion (with source code)

Source: Internet
Author: User

Front-end page

 <  Head runat  =  "  Server  "  >  
< Title > No title page </ Title >

< Script SRC = " JS/jquery-1.5.1.min.js " Type = " Text/JavaScript " > </ Script >

< Script SRC = " JS/demo. js " Type = " Text/JavaScript " > </ Script >

</ Head >
< Body >
< Form ID = " Form1 " Runat = " Server " >
< Div ID = " Content " >
< Table >
< ASP: repeater ID = " Repeater1 " Runat = " Server " >
< Headertemplate >
< Tr >
< TD >
< Input type = " Checkbox " >
</ TD >
< TD >
Student ID
</ TD >
< TD >
Student name
</ TD >
</ Tr >
</ Headertemplate >
< Itemtemplate >
< Tr >
< TD >
< Input type = " Checkbox " >
</ TD >
< TD Style = " Text-align: Center " >
<% # Eval ( " Studentid " ) %>
</ TD >
< TD Style = " Text-align: Center " >
<% # Eval ( " Name " ) %>
</ TD >
</ Tr >
</ Itemtemplate >
</ ASP: Repeater >
</ Table >
</ Div >
< Div >
< Input ID = " Btndel " Type = " Button " Value = " Delete " > </ Input >
</ Div >
</ Form >
</ Body >

Background

  Protected     Void  Page_load (  Object  Sender, eventargs E)
{
Studentbll _ BLL = New Studentbll ();
If (Request. querystring [ " ID " ] ! = "" && Request. querystring [ " ID " ] ! = Null )
{
String _ IDS = Request. querystring [ " ID " ];
_ BLL. Delete (_ IDs );
}

Repeater1.datasource = _ BLL. selectall ();
Repeater1.databind ();
}

Demo. JS File

 $ (  Function  (){

// This function removes spaces and line breaks at the beginning and end of a string in JavaScript.
Function Trim (STR)
{
VaR Statrindex;
VaR Endindes;
For (I = 0 ; I < Str. length; I ++ )
{
VaR K = Str. charat (I );
If (K ! = " \ N " && K ! = " " )
{
Statrindex = I; Break ;
}
}
For (I = Str. Length - 1 ; I < Str. length; I -- )
{
VaR K = Str. charat (I );
If (K ! = " \ N " && K ! = " " )
{
Endindes = I; Break ;
}
}
Return Str. substring (statrindex, endindes + 1 );
};


$ ( " # Btndel " ). Click ( Function (){
VaR IDS = " '' " ;
$ ( " # Content input: checked " ). Parent (). Next (). Each ( Function (I ){
IDS = IDS + " ,' " + Trim ($ ( This ). Text ()) + " ' " ;
});
$ ( " # Content " ). Load ( " Default. aspx? Id = " + Encodeuri (IDS) + " # P-getting-started # Content " ) // Partial update Repeater
})


})

 

source code download

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.