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