Use of the data binding control Repeater

Source: Internet
Author: User

 

 

Aspx code

<% @ Page Language = "C #" autoeventwireup = "true" codebehind = "default. aspx. cs" inherits = "Data Binding. _ default" %> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml"> 

Aspx. CS code

Using system; using system. collections. generic; using system. LINQ; using system. web; using system. web. ui; using system. web. UI. webcontrols; using data binding. dal. dataset1tableadapters; using system. data; using system. web. UI. htmlcontrols; namespace Data Binding {public partial class _ default: system. web. UI. page {protected void page_load (Object sender, eventargs e) {} protected void repeaterincluitemcommand (Object source, re Peatercommandeventargs e) {t_usertableadapter adapter = new t_usertableadapter (); If (E. commandname = "enabled") {adapter. updateenabled (convert. toint32 (E. commandargument); repeater1.databind ();} else {adapter. updatedisabled (convert. toint32 (E. commandargument); repeater1.databind () ;}} protected void repeaterincluitemdatabound (Object sender, repeateritemeventargs e) {If (E. item. itemtype = lis Titemtype. item | E. item. itemtype = listitemtype. alternatingitem) {datarowview viewrow = (datarowview) E. item. dataitem; var ROW = (data binding. dal. dataset1.t _ userrow) viewrow. row; If (row. state = "enabled") {button btnq = (button) E. item. findcontrol ("btnenabled"); btnq. visible = false;} else if (row. state = "disabled") {htmltablerow rcolor = (htmltablerow) E. item. findcontrol ("hrcolor"); rcolor. attributes ["class"] = "Ni"; button btnj = (button) E. item. findcontrol ("btndisabled"); btnj. visible = false;} else {Throw new exception ("invalid state! ");}}}}}

  

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.