473,386 Members | 1,726 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,386 software developers and data experts.

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 2858
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ole M | last post by:
I'm having some trouble using the ObjectDataSource in ASP.NET 2.0. I have a wrapper that contains the static methods for Select and Update. The Update-method takes the business object as...
2
by: Kjetil Klaussen | last post by:
Hi, I’m having some troubles trying to bind my dataset to a GridView control through an ObjectDataSource control. The binding works fine for regular columns in my dataset, but I can’t seem...
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
0
by: Bryce Fischer | last post by:
I've got a simple (I think) asp.net application. I've created a DataSet in App_Code/ItemDataSet.xsd. Tested connection, seemed to work fine. In my ASPX file, I first dropped an...
5
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are...
0
by: GMartin | last post by:
I have a pop-up form with a three columned Grid that has checkboxes in a Template Column in the first/left-most column. (The form is to allow users to select "Members" of a group, where they check...
0
by: Phillip Ian | last post by:
Tried this over in CSharp.General and didn't get anything, so I thought I'd try again here. If there's an AJAX specific group I could ask this in, please let me know...I did look. I'm trying to...
2
by: rgparkins | last post by:
So, I've bitten the bullet and am converting some of my asp.net 1.1 sites to asp.net 2.0, now after many issues I have come to a stop with the objectdatasource and gridviews and maybe someone can...
2
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
Based on wether a row is selected in a GridView I need to HIDE the last two columns of a gridview. I do NOT need to make the cells invisible I want to hide the entire column. When I set the...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.