If the GridView gender column is a Boolean field in the database, which is true or false, how can it be displayed as a man or a woman on the page?

Source: Internet
Author: User

The image above is the part of the GridView bound to the background database. The fourth column shows the gender column. The data type in the background database is boolean. The values are true or false. If the value is true, the data type is male. If the value is false, the data type is female...

What we are talking about today is to display the Gender column on the browser page as men and women rather than true and false when reading gender from the background database.

Many people have said that it is not okay to directly write in the query statement. Yes, this method is feasible.

Today, I will use the RowDataBound bound to the GridView to implement it...

At the front-end of the page, I will not write more (roughly the same). I will only write the Gender column as an example:

<Asp: BoundField DataField = HeaderText = ItemStyle-HorizontalAlign => <ItemStyle HorizontalAlign = Height => </ItemStyle> </asp: BoundField>

This is a prerequisite for Data Binding. Note the attributes DataField and SortExpression. If not, you cannot bind background data to the page even if you have written a query statement.

After preparing the front-end page, the RowDataBound event that triggers the GridView is as follows:

GridView_RowDataBound (e. row. rowType = (e. row. cells []. text =]. text = (e. row. cells []. text. toString () =]. text =

I believe you can understand this code. If you don't talk about it much, you can see that gender is listed as male and female...

There is no technical content, and it is not any innovative code. The post is just for you to understand the usage of this gridView_RowDataBound event.

For reference only !!!

Related Article

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.