Re: creating usercotrols from webcontrol
- From: "Ersin Gençtürk" <ers[spam]@gencturk.org>
- Date: Tue, 24 May 2005 13:30:29 +0300
I am gettin these errors :
[NullReferenceException: Object reference not set to an instance of an
object.]
Project.Controls.ListSelection.set_DataValueField(String value) in
c:\inetpub\wwwroot\nexumportal2\controls\listselection.ascx.cs:123
Project.Controls.NexumProductGroups.CreateChildControls() in
c:\inetpub\wwwroot\nexumportal2\controls\nexumproductgroups.cs:57
System.Web.UI.Control.EnsureChildControls() +92
System.Web.UI.Control.PreRenderRecursiveInternal() +38
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Page.ProcessRequestMain() +1499
I can set Controls.ListSelection.DataValue property when I use this control
from a webpage.
"Ersin Gençtürk" <ers[spam]@gencturk.org> wrote in message
news:elKQhwDYFHA.252@xxxxxxxxxxxxxxxxxxxxxxx
> hi , I am trying to add a usercontrol to the control collection of a
> webcontrol but I get "Object reference not set to an instance of an
object."
> errors.On the other hand , by changing the code creating Usercontrol to
> create a Webcontrol (label ,textbox etc) I can use it successfully.I think
> there is a problem with childcontrolscreating.Is there any ideas ?
>
> Note that : ListSelection is my user control.
>
> -ersin gençtürk
>
> I am sending the source code below :
>
> public class ProductGroups: System.Web.UI.WebControls.WebControl,
> INamingContainer
>
> {
>
> private bool _EditMode;
>
>
> public ProductGroups()
>
> {
>
> }
>
> /// <summary>
>
> /// Turns control into editing mode
>
> /// </summary>
>
> public bool EditMode
>
> {
>
> get
>
> {
>
> return(_EditMode);
>
> }
>
> set
>
> {
>
> _EditMode=value;
>
> }
>
> }
>
>
> protected override void CreateChildControls()
>
> {
>
> base.CreateChildControls ();
>
> this.EnsureChildControls();
>
> if (EditMode)
>
> {
>
> ListSelection ListSelection1=new ListSelection();
>
> ListSelection1.DataValueField="ProductGroupId";
>
> ListSelection1.DataTextField="ProductGroupName";
>
> ListSelection1.NotSelectedItemsDataSource=//Some datasource code.
>
> ListSelection1.NotSelectedItemsDataBind();
>
> Controls.Add(ListSelection1);
>
>
> }
>
> else
>
> {
>
> Controls.Add(ProductGroupList1);
>
> }
>
>
>
> }
>
> }
>
>
.
- Follow-Ups:
- Re: creating usercotrols from webcontrol
- From: Ersin Gençtürk
- Re: creating usercotrols from webcontrol
- References:
- creating usercotrols from webcontrol
- From: Ersin Gençtürk
- creating usercotrols from webcontrol
- Prev by Date: Re: Question about strong-name dlls
- Next by Date: Re: Small Error ASP.NET C#
- Previous by thread: creating usercotrols from webcontrol
- Next by thread: Re: creating usercotrols from webcontrol
- Index(es):
Relevant Pages
|