Customize the style and settings of the page navigation by configuring the pagerstyle and pagersettings properties respectively

Source: Internet
Author: User
Tags connectionstrings
Document directory
  • All code:
  • Web. config code:
  • Result:
Key code segment:

<Pagersettings mode = "nextpreviusfirstlast" position = "topandbottom" firstpageimageurl = "~ /Images/first.gif"
Lastpageimageurl = "~ /Images/last.gif "nextpageimageurl = "~ /Images/next.gif "previouspageimageurl = "~ /Images/prev.gif "/>
<Pagerstyle forecolor = "white" horizontalalign = "right" backcolor = "#284775"/>

All code:

<% @ Page Language = "C #" %>
<HTML>
<Head id = "head1" runat = "server">
<Title> sorting data using gridview </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Asp: gridview id = "gridview1" allowsorting = "true" allowpaging = "true" runat = "server" performanceid = "sqlperformance1"
Autogeneratecolumns = "false">
<Pagersettings mode = "nextpreviusfirstlast" position = "topandbottom" firstpageimageurl = "~ /Images/first.gif"
Lastpageimageurl = "~ /Images/last.gif "nextpageimageurl = "~ /Images/next.gif "previouspageimageurl = "~ /Images/prev.gif "/>
<Pagerstyle forecolor = "white" horizontalalign = "right" backcolor = "#284775"/>

<Columns>
<Asp: boundfield headertext = "ID" datafield = "au_id" sortexpression = "au_id"/>
<Asp: boundfield headertext = "last name" datafield = "au_lname" sortexpression = "au_lname"/>
<Asp: boundfield headertext = "first name" datafield = "au_fname" sortexpression = "au_fname"/>
<Asp: boundfield headertext = "phone" datafield = "phone" sortexpression = "phone"/>
<Asp: boundfield headertext = "Address" datafield = "Address" sortexpression = "Address"/>
<Asp: boundfield headertext = "city" datafield = "city" sortexpression = "city"/>
<Asp: boundfield headertext = "state" datafield = "state" sortexpression = "state"/>
<Asp: boundfield headertext = "zip code" datafield = "Zip" sortexpression = "Zip"/>
<Asp: checkboxfield headertext = "contract" sortexpression = "contract" datafield = "contract"/>
</Columns>
</ASP: gridview>
<Asp: sqldatasource id = "sqldatasource1" runat = "server"
Selectcommand = "select [au_id], [au_lname], [au_fname], [PHONE], [address], [City], [State], [Zip], [contract] from [authors]"
Connectionstring = "<% $ connectionstrings: pubs %>"/>
</Form>
</Body>
</Html>
 

Web. config code:

? XML version = "1.0"?>
<Configuration>
<Connectionstrings>

<Add name = "pubs" connectionstring = "Server = localhost; uid = sa; Pwd = 123456; database = pubs;" providername = "system. Data. sqlclient"/>



</Connectionstrings>
<System. Web>
<Compilation DEBUG = "true"/>
 
<Caching>
<Sqlcachedependency enabled = "true" polltime = "1000">
<Databases>
<Add name = "pubs" connectionstringname = "pubs"/>
</Databases>
</Sqlcachedependency>
</Caching>
</System. Web>
</Configuration>

Result:

ID Last name First name Phone Address City State Zip code Contract
172 to 32-1176 White Johnson 408 496-7223 10932 bigge Rd. Menlo Park CA 94025
213 to 46-8915 Green Marjorie 415 986-7020 309 63rd st. #411 Oakland CA 94618
238-95-7766. Carson Cheryl 415 548-7723 589 Darwin ln. Berkeley CA 94705
267 to 41-2394 O 'Leary Michael 408 286-2428 22 Cleveland Av. #14 San Jose CA 95128
September 274-80-9391 Straight Dean 415 834-2919 5420 college Av. Oakland CA 94609
September 341-22-1782 Smith Meander 913 843-0462 10 Mississippi dr. Lawrence KS 66044
409 to 56-7008 Bennet Abraham 415 658-9932 6223 Bateman St. Berkeley CA 94705
427-17-2319 Dull Ann 415 836-7128 3410 blonde St. Palo Alto CA 94301
472-27-2349 Gringlesby Burt 707 938-6445 PO Box 792 Covelo CA 95428
486 to 29-1786 Locksley Charlene 415 585-4620 18 Broadway Av. San Francisco CA 94130

 

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.