programatically databinding

J

John

Hi,

heres a brief description of what I'm trying to do.

I have a sql table named colors that looks like this:

color_id color_name
1 blue
2 red
3......... and so on

I created a composite custom control overode the
CreateChildControls method where I created a Datalist that
has one child control (a button). I want to bind the
color from my sql table to the button's foreground color

When I include this control into a aspx page i want to see
3 buttons (or as many buttons as I have colors in my
table). I'm having trouble with how to properly databind
to programatically databind to this datalist
programatically

thanks for the help

-J
 
N

Nicholas Paldino [.NET/C# MVP]

John,

I don't think that ASP.NET controls have this kind of binding in them.
Windows forms would allow you to specify a data source, as well as a
property of that data source, and specify the property you want set as a
result.

I think you will have to set the control color manually, depending on
the color name, as I don't think that web controls support this level of
data binding.

Hope this helps.
 
G

Guest

I'm not sure I understand. If I create a regular aspx
page. Create a DataAdapter and generate a dataset and
then put a datalist on the page. I can set the datasource
and datamember properties of the datalist. Then I can put
a button in the datalist, go to it's databinding
properties and bind any of the button's bindable
properties to a column from the dataset. It generates
something like the following in html
Databinder.Eval(Container, "DataItem.color") ...

I'm not sure what you meant by "ASP.NET controls dont have
this kind of binding" maybe I'm misunderstanding you.

thanks

John
-----Original Message-----
John,

I don't think that ASP.NET controls have this kind of binding in them.
Windows forms would allow you to specify a data source, as well as a
property of that data source, and specify the property you want set as a
result.

I think you will have to set the control color manually, depending on
the color name, as I don't think that web controls support this level of
data binding.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,

heres a brief description of what I'm trying to do.

I have a sql table named colors that looks like this:

color_id color_name
1 blue
2 red
3......... and so on

I created a composite custom control overode the
CreateChildControls method where I created a Datalist that
has one child control (a button). I want to bind the
color from my sql table to the button's foreground color

When I include this control into a aspx page i want to see
3 buttons (or as many buttons as I have colors in my
table). I'm having trouble with how to properly databind
to programatically databind to this datalist
programatically

thanks for the help

-J


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top