Gridview operation: basic operation (edit, update, cancel)

Source: Internet
Author: User
Basic operation of the gridview: Edit event: rowediting 1 protected void gridviewinclurowediting (Object sender, gridviewediteventargs E)
2 {
3gridview1. editindex = E. neweditindex;
4gridview_databind (); // you need to bind it again.
5}

Basic operation of the gridview: Update event: rowupdating 1 protected void gridview1_rowupdating (Object sender, gridviewupdateeventargs E)
2 {
3int click, score, times;
4 string name;
5
6if (Reg. ismatch (textbox) gridview1.rows [E. rowindex]. cells [3]. controls [0]). Text ))
7 {
8 click = int. parse (textbox) gridview1.rows [E. rowindex]. cells [3]. controls [0]). Text );
9}
10 else
11 {
12 click = int. parse (gridview1.rows [E. rowindex]. cells [3]. Text );
13}
14 // in the source code, the gridview is implemented using templatefield, but it can also be used to obtain the value of a cell.
15 // you can also use row [E. rowindex]. findcontrol ("Control ID") to obtain the control and perform type conversion.
16 score = int. parse (textbox) gridview1.rows [E. rowindex]. cells [2]. controls [0]). Text );
17 times = int. parse (textbox) gridview1.rows [E. rowindex]. cells [1]. controls [0]). Text );
18 name = gridview1.rows [E. rowindex]. cells [0]. text;
19 // call the database update Method
20 string message = GP. updatepinlun (click, times, score, name );
21 // disable edit mode
22gridview1. editindex =-1;
23 // rebind data
24gridview_databind ();
25}

Basic operation of the gridview: cancel the update event: rowcancelingedit 1 protected void gridview1_rowcancelingedit (Object sender, gridviewcancelediteventargs E)
2 {
3 // disable the editing mode
4gridview1. editindex =-1;
5 // Data Binding
6gridview_databind ();
7}

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.