Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / April 2006

Tip: Looking for answers? Try searching our database.

[C#]My first CompositeDataBoundControl

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mehdi_tn - 13 Apr 2006 23:29 GMT
Hi, and thanks for this forum

I'm trying to build a new control composed of an Image and
dropdownlis

First I succed to build the control extending from DataBoiundContro
this my fast code and it works perfectly

[ToolboxData("<{0}:Picturelis
runat=server></{0}:Picturelist>")
   public class Picturelist : DataBoundContro
   
       private Image _image
       private DropDownList _dropList
       private Literal lt

protected override void CreateChildControls(
       
           Controls.Clear()

           _image = new Image()
           _dropList = new DropDownList()
           lt = new Literal()

           lt.Text = "</br>"

           this.Controls.Add(_image)
           this.Controls.Add(lt)

           this.Controls.Add(_dropList)
           base.CreateChildControls()
           //return 0

       
     

// only my ddl is shown for the momen
protected override void Render(HtmlTextWriter output
       
           _dropList.RenderControl(output)
       

protected override voi
PerformDataBinding(System.Collections.IEnumerabl
dataSource
       
           base.PerformDataBinding(dataSource)

           if (dataSource != null
           
               List<String> l = ne
List<String>()

               foreach (object o in dataSource
               

                   l.Add(DataBinder.GetPropertyValue(o
"nom", null));
               
               _dropList.DataSource = l

               _dropList.DataBind()

           
       
   

As u see, in the render method I only show my ddl control, but know m
PictureList control must extend the CompositeDataboundContol so I ca
show both ddl and the image, I know that I have to override th
method

[code:1:b8f71b2038
protected override int
CreateChildControls(System.Collections.IEnumerable dataSource
bool dataBinding
[/code:1:b8f71b2038

but I didnt know how to use it for binding my ddl instead of usin
PerformDataBindin

Thanks in advanc

---------------------------------
http://community.ihostasp.ne
ASP.NET Developer Community
Teemu Keiski - 15 Apr 2006 10:15 GMT
Hi,

here's a good article covering the base for this

A Crash Course on ASP.NET Control Development: Building Composite Controls
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/ASP
NETContDev.asp


It has a section "Building a Composite Data-Bound Control" which you'd want
to see

Thereäs also another companion article:

Building Data-Bound controls
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/Con
tCrshCrsDB.asp


Signature

Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

> Hi, and thanks for this forum,
>
[quoted text clipped - 81 lines]
> http://community.ihostasp.net
> ASP.NET Developer Community

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.