GridView PreRender Event and Example--gridview + checkbox, click multiple columns (check delete)

Source: Internet
Author: User

GridView PreRender Event and Example--gridview + checkbox, click multiple columns (check delete)

 

before there is an example, the same results can be used in two ways to practice

[GridView] data binding expression? Or a RowDataBound event?

I think this teaching method is very good, "the same topic, there are many solutions "

(as the Bruce Lee picture below says, "proficiency" is important)

Students respond more warmly, can also choose their own habits, their own (the current level) to learn the way to deal with

to be a successful person in the workplace, Bruce Lee's spirit you should learn! http://buzzorange.com/vidaorange/2015/07/17/bruce-jun-fan-lee-quote/

(Click the image to connect to the original text)

There's a reader who wants to know The PreRender event for the control ?

Why surf the Internet to find "gridview merge fields, merge the same records" are all in the GridView PreRender event completed? "

Let's start with a few examples and then take a look at the MSDN Web site's instructions

First, "Do" and then "learn", hoping to make you better understand.

Take the previous example and use the PreRender event of the GridView to do

Exercise FindControl Simple Practice--gridview + checkbox, click Multi-column data (check delete) #1 simple [exercise] FindControl Simple exercise--gridview + checkbox, click Multi-column data (check delete) #2-pagination &A MP; Sample Download

The original example, in book last episode (ASP. NET thematic Practice (I)/Songgang Publishing) The tenth chapter has a commentary

Take a look at YouTube videos and get an overview of what we're going to do:

YouTube video tutorial https://youtu.be/LnYXiyQghKs


Q: In the GridView, each column of data is added with a CheckBox,

The column that is checked will be deleted.

Change the original RowDataBound incident to a PreRender event to do, there are two major changes:

First, in the RowDataBound event, the IF (E.row.rowtype) discriminant disappears.

So you have to write a for loop yourself.

Second, use to E.row ... Place, change to gridview1.rows[i] can

protected void gridview1_ PreRender (object sender, EventArgs e)

    {if (session["delete_id"]. ToString ()! = ...)        {for (int i = 0; i < GridView1.Rows.Count; i++)            {checkbox MyCheckBox = (checkbox) gridview1.rows[i]. FindControl ("CheckBox1");Label MyID = (label) Gridview1.rows[i]. FindControl ("Label1");                //..... Subsequent omission ..... Apply the previous example directly            }        }    }

=========================================================================

when you're done, let's look at the instructions on the MSDN website-- The PreRender event for the control

...... Occurs after the Control object has been loaded but before rendering .

After doing a few examples, for the original description, will not compare "feelings"?

Therefore, to rely on the practice, examples to "experience", you must practice! Get your hands on it! Design your own situation!

You can't just read a book or read a word. This is not a school test? It 's not a question of " right or wrong, a choice, a proposition."

The thing "writes" does not come out to be miserable,

The boss and the client don't care how good our school grades are, he wants to see the results of the program "working properly"

=========================================================================

If you have an answer, you have "multiple" solutions to handle

Congratulations! It's apprenticeship!

Similar examples:

The PreRender event and example of the GridView--[case Study] a score of less than 60 appears on the Red Letter & fractions plus Total (cumulative)

GridView PreRender Event and Example--gridview + checkbox, click multiple columns (check delete)

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.