ASP. NET web control (7) (pagination datalist)

Source: Internet
Author: User

I didn't want to write this article, but because of a problem with the paging control style, I have corrected it now, so I 'd like to find something to post.

There is still an error in the design of the encapsulation. It is not supported in the same way as the repeater, And the level is not enough.

Later, I made a stupid method to output a segment in the designMode. It is a bit, but it will not affect the runtime.

<Hxj: pagedatalist id = "pagedatalist1" runat = "server" pageindexbox = "dropdownlist"
Repeatcolumns = "4" pagesize = "8" backcolor = "white" bordercolor = "# dedfde"
Borderstyle = "NONE" borderwidth = "1px" cellpadding = "4" forecolor = "black"
Gridlines = "vertical" pagealign = "right" width = "100%" enableviewstate = "false">
<Footerstyle backcolor = "# cccc99"/>
<Itemstyle backcolor = "# f7f7de"/>
<Itemtemplate>
Productid:
<%
   1: # Eval("ProductID")

%>
<Br/>
Productname:
<%

   1: # Eval("ProductName")

%>
</Itemtemplate>
<Selecteditemstyle backcolor = "# ce5d5a" font-bold = "true" forecolor = "white"/>
<Headerstyle backcolor = "# 6b696b" font-bold = "true" forecolor = "white"/>
<Alternatingitemstyle backcolor = "white"/>
</Hxj: pagedatalist>

 

Design Timeliness:

The original design has been wrong, and the technology is not enough. It is difficult to solve this problem only when there is more code. The following code:

Base. Render (writer );
If (! DesignMode)
Pagerhelper. Render (writer );
Else
{
If (! String. isnullorempty (pagecssclass ))
{
Writer. addattribute (htmltextwriterattribute. Class, pagecssclass );
}
Else
{
Writer. addattribute (htmltextwriterattribute. class, "pagedefault ");
}
If (! String. isnullorempty (pagestyle ))
{
Writer. addattribute (htmltextwriterattribute. style, pagestyle );
}
Writer. addstyleattribute (htmltextwriterstyle. textalign, pagealign. tostring ());
Writer. addattribute (htmltextwriterattribute. ID, uniqueid + "Div ");
Writer. renderbegintag (htmltextwritertag. Div );

Writer. write (string. concat ("Number", currentpageindex. tostring (), "/", pagecount. tostring (), "page, page", pagesize. tostring (), "entries, total", recordcount. tostring (), "Entries & nbsp ;"));

Writer. renderbegintag (htmltextwritertag. span );
Writer. Write ("<");
Writer. renderendtag ();
Writer. renderbegintag (htmltextwritertag. span );
Writer. Write ("<");
Writer. renderendtag ();
Writer. renderbegintag (htmltextwritertag. span );
Writer. Write ("1 ");
Writer. renderendtag ();
Writer. renderbegintag (htmltextwritertag. span );
Writer. Write ("> ");
Writer. renderendtag ();
Writer. renderbegintag (htmltextwritertag. span );
Writer. Write ("> ");
Writer. renderendtag ();

If (pageindexbox = pageindexboxtype. textbox)
{
Writer. addattriter( htmltextwriterattribute. ID, uniqueid + "_ INPUT ");
Writer. addattribute (htmltextwriterattribute. Name, uniqueid + "_ INPUT ");
Writer. addattribute (htmltextwriterattribute. type, "text ");
Writer. addstyleattribute (htmltextwriterstyle. Width, "30px ");
Writer. addattribute (htmltextwriterattribute. Value, currentpageindex. tostring ());
Writer. renderbegintag (htmltextwritertag. Input );
Writer. renderendtag ();

Writer. addattribute (htmltextwriterattribute. ID, uniqueid + "_ BTN ");
Writer. addattribute (htmltextwriterattribute. Name, uniqueid + "_ BTN ");
Writer. addattribute (htmltextwriterattribute. type, "button ");
Writer. addattribute (htmltextwriterattribute. value, "go ");
Writer. renderbegintag (htmltextwritertag. Input );
Writer. renderendtag ();
}
Else if (pageindexbox = pageindexboxtype. dropdownlist)
{
Writer. Write ("go ");
Writer. addattriter( htmltextwriterattribute. ID, uniqueid + "_ INPUT ");
Writer. addattribute (htmltextwriterattribute. Name, uniqueid + "_ INPUT ");
Writer. renderbegintag (htmltextwritertag. Select );
For (INT I = 1; I <= pagecount; I ++)
{
Writer. addattribute (htmltextwriterattribute. value, I. tostring ());
If (I = currentpageindex)
{
Writer. addattribute (htmltextwriterattribute. Selected, "true ");
}
Writer. renderbegintag (htmltextwritertag. Option );
Writer. Write (I. tostring ());
Writer. renderendtag ();
}
Writer. renderendtag ();
Writer. Write ("page ");
}

Writer. renderendtag ();
}

As a result, there is so much code below else, but it does not affect the runtime.

 

CS code:

protected void Page_Load(object sender, EventArgs e){}protected void Page_PreRender(object sender, EventArgs e){    PageDataList1.FromSection = DbSession.Default.From<Products>().OrderBy(Products._.ProductID.Asc);    PageDataList1.DataBind();}

 

The runtime is as follows:

The default style is also modified, and the output of the previous paging control is faulty, which makes the style ineffective.

 

Style: pagecssclass = "Badoo"

 

Style: pagecssclass = "Scott"

 

For details about various CSS styles, see section 5. There are more than 20 paging styles.

 

 

Download

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.