I was frustrated. Now I found that the gridview can use a custom template like datalist.

Source: Internet
Author: User

I was frustrated. Now I found that the gridview can use a custom template like datalist, which I never thought would work .~

Today, I am lazy. I am working on the background. I don't want to implement custom pages. I want to use the pagination that comes with the gridview... so I learned the following things !!!

The design view is as follows: only the sqldatasource data source control is used.

Apply the format to the gridview. Run the following:(Note: The paging effect is normal)

HtmlSource codeAs follows:

Code

  <  ASP: gridview  ID  = "Gridview1"  Runat = "Server"  Autogeneratecolumns  = "False"  Performanceid  = "Sqlperformance1"  
Allowpaging = "True" Backcolor = "White" Bordercolor = "#999999" Borderstyle = "NONE"
Borderwidth = "1px" Cellpadding = "3" Gridlines = "Vertical" Pagesize = "1" >
< Rowstyle Backcolor = "# Eeeeee" Forecolor = "Black" />
< Columns >
< ASP: templatefield >
< Itemtemplate >
< Table Width = "100%" Border = "1" Cellspacing = "0" Cellpadding = "0" >
< Tr >
< TD >
< ASP: Label ID = "Label4" Runat = "Server" Text = '<% # BIND ("Ntitle") % > '> </ ASP: Label >
</ TD >
< TD >
< ASP: Label ID = "Label5" Runat = "Server" Text = '<% # BIND ("ndate") % > '> </ ASP: Label >
</ TD >
< TD >
Price
</ TD >
</ Tr >
< Tr >
< TD Colspan = "3" >
< ASP: Label ID = "Label6" Runat = "Server" Text = '<% # BIND ("ndescription") % > '> </ ASP: Label >
</ TD >
</ Tr >
< Tr >
< TD Colspan = "3" >
< HR />
</ TD >
</ Tr >
</ Table >
</ Itemtemplate >
</ ASP: templatefield >
</ Columns >
< Footerstyle Backcolor = "# Cccccc" Forecolor = "Black" />
< Pagerstyle Backcolor = "#999999" Forecolor = "Black" Horizontalalign = "Center" />
< Selectedrowstyle Backcolor = "# 008a8c" Font-bold = "True" Forecolor = "White" />
< Headerstyle Backcolor = "#000084" Font-bold = "True" Forecolor = "White" />
< Alternatingrowstyle Backcolor = "# Dcdcdc" />
</ ASP: gridview >
< ASP: sqldatasource ID = "Sqlperformance1" Runat = "Server" Connectionstring = "Data Source =.; initial catalog = yingcedb; persist Security info = true; user id = sa; Password ="
Providername = "System. Data. sqlclient" Selectcommand = "Select [Ntitle], [ndate], [ndescription], [nkeyword] from [yingce_new]" >
</ ASP: sqldatasource >

 

 

 

Game over! Thank you !! Hoho... don't swear .~~

 

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.