469,643 Members | 2,064 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Retrieving ObjectDataSource columns

I have a simple data object that returns two columns in a dataset, ID
and DESC, for example.

When I bind a dropdownlist to this <dataobjectmethod>, I have to
manually enter the column names for the ID and value. How do I make
the schema available?

Oct 17 '07 #1
7 2682
Larry Bud wrote:
I have a simple data object that returns two columns in a dataset, ID
and DESC, for example.

When I bind a dropdownlist to this <dataobjectmethod>, I have to
manually enter the column names for the ID and value. How do I make
the schema available?
I don't quite understand what you mean by
How do I make the schema available?
but if what you want is to avoid having to
enter the column names for the ID and value
I think you have no other option rather than specifying the
DataTextField and DataValueField properties of the DropDownList, because
their default values are string.Empty. The only case you can avoid
specifying them is if your DataSource has only one field as specified in
http://msdn2.microsoft.com/en-us/lib...7(VS.80).aspx:
If the data source has only one field, you do not have to explicitly
set these fields, because the control will simply display the single field.

Regards

Poli
Oct 17 '07 #2
Poli García wrote:
Larry Bud wrote:
>I have a simple data object that returns two columns in a dataset, ID
and DESC, for example.

When I bind a dropdownlist to this <dataobjectmethod>, I have to
manually enter the column names for the ID and value. How do I make
the schema available?
I don't quite understand what you mean by
How do I make the schema available?
but if what you want is to avoid having to
enter the column names for the ID and value
I think you have no other option rather than specifying the
DataTextField and DataValueField properties of the DropDownList, because
their default values are string.Empty. The only case you can avoid
specifying them is if your DataSource has only one field as specified in
http://msdn2.microsoft.com/en-us/lib...7(VS.80).aspx:
If the data source has only one field, you do not have to explicitly
set these fields, because the control will simply display the single field.

Regards

Poli
The link is: http://msdn2.microsoft.com/en-us/lib...77(VS.80).aspx
Oct 17 '07 #3
On Oct 17, 11:44 am, Poli García <poligar...@gmail.comwrote:
Larry Bud wrote:
I have a simple data object that returns two columns in a dataset, ID
and DESC, for example.
When I bind a dropdownlist to this <dataobjectmethod>, I have to
manually enter the column names for the ID and value. How do I make
the schema available?

I don't quite understand what you mean by
How do I make the schema available?
but if what you want is to avoid having to
enter the column names for the ID and value
I think you have no other option rather than specifying the
DataTextField and DataValueField properties of the DropDownList, because
their default values are string.Empty. The only case you can avoid
specifying them is if your DataSource has only one field as specified inhttp://msdn2.microsoft.com/en-us/library/31723w77(VS.80).aspx:
If the data source has only one field, you do not have to explicitly
set these fields, because the control will simply display the single field.
So anytime I bind any data object, such as a GridView, to a
datasourceobject, I have to manually specify the column names?

Oct 17 '07 #4
Larry Bud wrote:
On Oct 17, 11:44 am, Poli García <poligar...@gmail.comwrote:
>Larry Bud wrote:
>>I have a simple data object that returns two columns in a dataset, ID
and DESC, for example.
When I bind a dropdownlist to this <dataobjectmethod>, I have to
manually enter the column names for the ID and value. How do I make
the schema available?
I don't quite understand what you mean by
> How do I make the schema available?
but if what you want is to avoid having to
> enter the column names for the ID and value
I think you have no other option rather than specifying the
DataTextField and DataValueField properties of the DropDownList, because
their default values are string.Empty. The only case you can avoid
specifying them is if your DataSource has only one field as specified inhttp://msdn2.microsoft.com/en-us/library/31723w77(VS.80).aspx:
If the data source has only one field, you do not have to explicitly
set these fields, because the control will simply display the single field.

So anytime I bind any data object, such as a GridView, to a
datasourceobject, I have to manually specify the column names?
Not at all, what I just said applies to DropDownList and the other
ListControls (ie: ListBox, RadioButtonList, CheckBoxList, DropDownList),
with a GridView you can get the columns automatically resolved if you
set the AutoGenerateColumns property to *true*:
http://msdn2.microsoft.com/en-us/lib...tecolumns.aspx

Regards
Oct 17 '07 #5
On 17 Oct, 16:15, Larry Bud <larrybud2...@yahoo.comwrote:
I have a simple data object that returns two columns in a dataset, ID
and DESC, for example.

When I bind a dropdownlist to this <dataobjectmethod>, I have to
manually enter the column names for the ID and value. How do I make
the schema available?
ObjectDataSources do not present database schema information at Design
Time in the same way as SQl or XML sources. The output from code
behind ObjectDatasources cannot be inferred by the designer. Like all
other objects and data that are created in code their output is
entirely unknown to the system until run-time.

HTH

Oct 17 '07 #6
On Oct 17, 2:45 pm, Phil H <goo...@philphall.me.ukwrote:
On 17 Oct, 16:15, Larry Bud <larrybud2...@yahoo.comwrote:
I have a simple data object that returns two columns in a dataset, ID
and DESC, for example.
When I bind a dropdownlist to this <dataobjectmethod>, I have to
manually enter the column names for the ID and value. How do I make
the schema available?

ObjectDataSources do not present database schema information at Design
Time in the same way as SQl or XML sources. The output from code
behind ObjectDatasources cannot be inferred by the designer. Like all
other objects and data that are created in code their output is
entirely unknown to the system until run-time.

Thanks, glad to know I wasn't going nuts. I was hoping there was
some way to define what the columns would be, but I guess not.


Oct 18 '07 #7
On Oct 17, 2:14 pm, Poli García <poligar...@gmail.comwrote:
Larry Bud wrote:
On Oct 17, 11:44 am, Poli García <poligar...@gmail.comwrote:
Larry Bud wrote:
I have a simple data object that returns two columns in a dataset, ID
and DESC, for example.
When I bind a dropdownlist to this <dataobjectmethod>, I have to
manually enter the column names for the ID and value. How do I make
the schema available?
I don't quite understand what you mean by
How do I make the schema available?
but if what you want is to avoid having to
enter the column names for the ID and value
I think you have no other option rather than specifying the
DataTextField and DataValueField properties of the DropDownList, because
their default values are string.Empty. The only case you can avoid
specifying them is if your DataSource has only one field as specified inhttp://msdn2.microsoft.com/en-us/library/31723w77(VS.80).aspx:
If the data source has only one field, you do not have to explicitly
set these fields, because the control will simply display the single field.
So anytime I bind any data object, such as a GridView, to a
datasourceobject, I have to manually specify the column names?

Not at all, what I just said applies to DropDownList and the other
ListControls (ie: ListBox, RadioButtonList, CheckBoxList, DropDownList),
with a GridView you can get the columns automatically resolved if you
set the AutoGenerateColumns property to *true*:http://msdn2.microsoft.com/en-us/lib...webcontrols.gr...
Sure, but not at design time. If I wanted to create template fields,
I'll have to do so manually.

Oct 18 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Ole M | last post: by
2 posts views Thread by Kjetil Klaussen | last post: by
reply views Thread by Bryce Fischer | last post: by
5 posts views Thread by Randy Smith | last post: by
reply views Thread by Phillip Ian | last post: by
2 posts views Thread by =?Utf-8?B?SmF5IFBvbmR5?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.