Execution sequence of the delete button event in the gridview

Source: Internet
Author: User
When a delete button exists in the gridview, I use btndel to add the event btndel_click to it and output the button run
Then add the gridview1_rowcommand method to output "rowcommand run"
Then add the gridview1_rowdeleting method to output "rowdeleting run"
On the execution page, click Delete. The output order is as follows:
Button run
Rowcommand run
Rowdeleting run
Therefore, we can use these three events to complete deletion. Generally, the first one is not very common and troublesome,
In the second rowcommand, add E. commandargument to the rowcommand and upload the ID to delete it.
The third type of rowdeleteing can be deleted directly. If you do not use the data source control, do not use E. keys, you can use gridview1.datakeys [E. rowindex]. value. tostring () gets the id value, which will be the same later ~ _~

Repeater frontend and backendCodeExecution sequence

The Code on the page is < ASP: repeater ID = " Repundo " Runat = " Server " Onitemdatabound = " Bindundo "   > < Itemtemplate >
...
< A href = " Todos_list.aspx " > <% = Newtr %> | <% # Newtr %> <% # Shownum (convert. toint64 (eval ( " Itemid " ))) %> Dinner </ A >
...
</ Itemtemplate > </ ASP: Repeater >

Background code Protected   Int Newtr =   0 ;
  Protected   Void Bindundo ( Object Sender, repeateritemeventargs E)
{
//Newtr = (newtr + 1) % 20;
Newtr=Newtr+200;
//Databinder. eval (E. Item. dataitem ,"");
}
Bind # Region Bind
Protected   String Shownum ( Long ID)
{
//Newtr = newtr ++;
Return(++Newtr). tostring ();
}
# Endregion

Running result:

402 | 0 | 1 dinner submitting... please wait the first item
402 | 201 | 202 dinner submitting... please wait the first item

This shows that:
1. the eval () method of the binding method of the page is executed first, as shown in <% #... %>.
2. Then run the bindundo method to bind the event.
3. Unified page output variable: Refers to <% =... %> outputting the content in the Variable

Note that:
The first step is to bind a data record. The third step is to output the data after the page is executed.

From the test above, we can infer the design of the execution sequence of Microsoft Asp.net events. First, the page is followed by the background. In fact, I want to bind the page data first and then trigger the event, the background is the method for triggering event execution

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.