Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Retrieving ObjectDataSource columns

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Larry Bud - 17 Oct 2007 16:15 GMT
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?
Poli García - 17 Oct 2007 16:44 GMT
> 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.
Phil H - 17 Oct 2007 19:45 GMT
> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.