Embedded datalist control in the repeart control-DOTNET Application and Development briefcase of Arain-

Source: Internet
Author: User
Tags dotnet

The nested datalist control in the repeart control usually displays data. datalist is preferred on webpages because it is flexible and has good style control. some specific functions need to be bound between data controls. but what if I bind another datalist in datalist? This efficiency is very low. When the functional conditions permit, repert should be given priority to datalist nesting.

Below isExample of nested datalist control in the repeart Control

Test. aspx




  • <% # Databinder. eval (container. dataitem, "name") %>



  • <% # Databinder. eval (container. dataitem, "title") %>





Test. aspx. CS

Protected void page_load (Object sender, eventargs E)


{


String SQL = "select * From nvwa_type order by ID ";


String connstring = "provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("~ /App_data/mydate. mdb ");


Oledbdataadapter ODA = new oledbdataadapter (SQL, connstring );


Dataset DS = new dataset ();


ODA. Fill (DS );


This. repeater1.datasource = Ds;


This. repeater1.databind ();


}


Protected void repeaterincluitemdatabound (Object sender, repeateritemeventargs E)


{


If (E. Item. itemtype = listitemtype. Item | E. Item. itemtype = listitemtype. alternatingitem)


{


String connstring = "provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("~ /App_data/mydate. mdb ");

Int type_id = convert. toint32 (datarowview) E. Item. dataitem). Row ["ID"]. tostring ());

Datalist DL = (datalist) E. Item. findcontrol ("datalist1"); // locate the datalist1 Control


If (type_id! = 0 & type_id! = NULL)


{


String SQL _p = "select * From nvwa_product where type =" + type_id + "order by ID ";


Oledbdataadapter ODA = new oledbdataadapter (SQL _p, connstring );


Dataset DS = new dataset ();


ODA. Fill (DS );


DL. datasource = Ds;


DL. databind ();


}

}


}

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.