> 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/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.
Regards
Poli
Poli García - 17 Oct 2007 16:50 GMT
>> I have a simple data object that returns two columns in a dataset, ID
>> and DESC, for example.
[quoted text clipped - 18 lines]
>
> Poli
The link is: http://msdn2.microsoft.com/en-us/library/31723w77(VS.80).aspx
Larry Bud - 17 Oct 2007 18:49 GMT
On Oct 17, 11:44 am, Poli Garc?a <poligar...@gmail.com> wrote:
> > I have a simple data object that returns two columns in a dataset, ID
> > and DESC, for example.
[quoted text clipped - 13 lines]
> 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?
Poli García - 17 Oct 2007 19:14 GMT
>>> I have a simple data object that returns two columns in a dataset, ID
>>> and DESC, for example.
[quoted text clipped - 14 lines]
> 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/library/system.web.ui.webcontrols.gridview.auto
generatecolumns.aspx
Regards
Larry Bud - 18 Oct 2007 16:21 GMT
On Oct 17, 2:14 pm, Poli Garc?a <poligar...@gmail.com> wrote:
> > On Oct 17, 11:44 am, Poli Garc?a <poligar...@gmail.com> wrote:
> >>> I have a simple data object that returns two columns in a dataset, ID
[quoted text clipped - 20 lines]
> with a GridView you can get the columns automatically resolved if you
> set the AutoGenerateColumns property to *true*:http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gr...
Sure, but not at design time. If I wanted to create template fields,
I'll have to do so manually.
> 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
Larry Bud - 18 Oct 2007 16:20 GMT
> > I have a simple data object that returns two columns in a dataset, ID
> > and DESC, for example.
[quoted text clipped - 8 lines]
> 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.