473,387 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Web Custom Control

I am building a web custom control that encapsulates a
series of dropdowns, buttons, etc. It is derived from a
WebControl. I have the control built so that it renders
properly. Now I am defining the public Bind() method so
that I can connect to various datasources via a
connection property I have defined.

The problem is that in my public Bind() method when I am
populating a dropdown using Datasource and DataBind, the
dropdown is not populated. I have the dropdown
(ddlbProduct) defined at the class level where I am
creating a new instance of the dropdown:

DropDownList ddlbProduct= new DropDownList();

I am placing it on my control in the CreateChildControls
() override like this:

thePageView.Controls.Add(ddlbProduct); // I'm putting the
dropdown inside of a PageView

I am binding the dropdown to a DataTable in my public Bind
() function like this:

ddlbProduct.DataSource = theDataSet.Tables[0];
ddlbProduct.DataValueField = "product_line";
ddlbProduct.DataTextField = "product_line_name";
ddlbProduct.DataBind();

When I step it through in debug I can see the instance of
ddlbProduct get populated correctly on the
ddlbProduct.DataBind() call. The instance that is
rendered on the page is not populated though. The only
time I am implicitly instantiating it is at the class
level.

I know this is probably an easy one. This is my first
custom control.

Thanks,

Steve
Nov 17 '05 #1
5 1230
In your public Bind() method you have to go private. This is not suitable to
be done publicly. It should only be done behind closed doors by consenting
adults.
"Steve R" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I am building a web custom control that encapsulates a
series of dropdowns, buttons, etc. It is derived from a
WebControl. I have the control built so that it renders
properly. Now I am defining the public Bind() method so
that I can connect to various datasources via a
connection property I have defined.

The problem is that in my public Bind() method when I am
populating a dropdown using Datasource and DataBind, the
dropdown is not populated. I have the dropdown
(ddlbProduct) defined at the class level where I am
creating a new instance of the dropdown:

DropDownList ddlbProduct= new DropDownList();

I am placing it on my control in the CreateChildControls
() override like this:

thePageView.Controls.Add(ddlbProduct); // I'm putting the
dropdown inside of a PageView

I am binding the dropdown to a DataTable in my public Bind
() function like this:

ddlbProduct.DataSource = theDataSet.Tables[0];
ddlbProduct.DataValueField = "product_line";
ddlbProduct.DataTextField = "product_line_name";
ddlbProduct.DataBind();

When I step it through in debug I can see the instance of
ddlbProduct get populated correctly on the
ddlbProduct.DataBind() call. The instance that is
rendered on the page is not populated though. The only
time I am implicitly instantiating it is at the class
level.

I know this is probably an easy one. This is my first
custom control.

Thanks,

Steve

Nov 17 '05 #2
I changed it so that I am calling a private method from
my public Bind() method. Still doesn't work.

I need a public method to do the bind so that I can set
the connection property first.
-----Original Message-----
In your public Bind() method you have to go private. This is not suitable tobe done publicly. It should only be done behind closed doors by consentingadults.


Nov 17 '05 #3
This is definitely too racey for me. Someone mark this thread XXX please.
"Steve R" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
I changed it so that I am calling a private method from
my public Bind() method. Still doesn't work.

I need a public method to do the bind so that I can set
the connection property first.
-----Original Message-----
In your public Bind() method you have to go private.

This is not suitable to
be done publicly. It should only be done behind closed

doors by consenting
adults.

Nov 17 '05 #4
So you were just BS'ing me on your original reply?
-----Original Message-----
This is definitely too racey for me. Someone mark this thread XXX please.


Nov 17 '05 #5
Does anyone else have any advice?

Thanks,

Steve
-----Original Message-----
I am building a web custom control that encapsulates a
series of dropdowns, buttons, etc. It is derived from a
WebControl. I have the control built so that it renders
properly. Now I am defining the public Bind() method so
that I can connect to various datasources via a
connection property I have defined.

The problem is that in my public Bind() method when I am
populating a dropdown using Datasource and DataBind, the
dropdown is not populated. I have the dropdown
(ddlbProduct) defined at the class level where I am
creating a new instance of the dropdown:

DropDownList ddlbProduct= new DropDownList();

I am placing it on my control in the CreateChildControls
() override like this:

thePageView.Controls.Add(ddlbProduct); // I'm putting thedropdown inside of a PageView

I am binding the dropdown to a DataTable in my public Bind() function like this:

ddlbProduct.DataSource = theDataSet.Tables[0];
ddlbProduct.DataValueField = "product_line";
ddlbProduct.DataTextField = "product_line_name";
ddlbProduct.DataBind();

When I step it through in debug I can see the instance ofddlbProduct get populated correctly on the
ddlbProduct.DataBind() call. The instance that is
rendered on the page is not populated though. The only
time I am implicitly instantiating it is at the class
level.

I know this is probably an easy one. This is my first
custom control.

Thanks,

Steve
.

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Christian H | last post by:
Hi! I've created a custom control (myDrawControl) that deals with drawing. This control is then added to a form( myMainForm) Now, whenever something is dragged and dropped onto myDrawControl ,...
15
by: Tinus | last post by:
Hello all, I've created a custom control that draws a monthly schedule (using the Draw function in C#). Basically it draws 31 boxes and writes the day number in every box. This works...
21
by: One Handed Man \( OHM - Terry Burns \) | last post by:
When using a custom control. In order to check and see if values have changed one has to implement the IPostBackDataCollection interface. The values returned for the control seem to be simply a...
1
by: Wannabe_Geek | last post by:
Hi Iam new to MS .Net technology just getting along with it....I created a custom control ,which takes in a query and displays the data in a tabular format....something similar to a datagrid. ...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
4
by: Smokey Grindle | last post by:
What is the best way to write dynamic controls in ASP.NET 2.0?
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.