Retrieving ObjectDataSource columns

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Larry Bud

    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 <dataobjectmeth od>, I have to
    manually enter the column names for the ID and value. How do I make
    the schema available?

  • =?ISO-8859-1?Q?Poli_Garc=EDa?=

    #2
    Re: Retrieving ObjectDataSourc e columns

    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 <dataobjectmeth od>, 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
    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

    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

    Comment

    • =?ISO-8859-1?Q?Poli_Garc=EDa?=

      #3
      Re: Retrieving ObjectDataSourc e columns

      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 <dataobjectmeth od>, 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
      Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

      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

      Comment

      • Larry Bud

        #4
        Re: Retrieving ObjectDataSourc e columns

        On Oct 17, 11:44 am, Poli García <poligar...@gma il.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 <dataobjectmeth od>, 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
        datasourceobjec t, I have to manually specify the column names?



        Comment

        • =?ISO-8859-1?Q?Poli_Garc=EDa?=

          #5
          Re: Retrieving ObjectDataSourc e columns

          Larry Bud wrote:
          On Oct 17, 11:44 am, Poli García <poligar...@gma il.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 <dataobjectmeth od>, 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
          >DataTextFiel d 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
          datasourceobjec t, 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 AutoGenerateCol umns property to *true*:


          Regards

          Comment

          • Phil H

            #6
            Re: Retrieving ObjectDataSourc e columns

            On 17 Oct, 16:15, Larry Bud <larrybud2...@y ahoo.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 <dataobjectmeth od>, I have to
            manually enter the column names for the ID and value. How do I make
            the schema available?
            ObjectDataSourc es do not present database schema information at Design
            Time in the same way as SQl or XML sources. The output from code
            behind ObjectDatasourc es 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

            Comment

            • Larry Bud

              #7
              Re: Retrieving ObjectDataSourc e columns

              On Oct 17, 2:45 pm, Phil H <goo...@philpha ll.me.ukwrote:
              On 17 Oct, 16:15, Larry Bud <larrybud2...@y ahoo.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 <dataobjectmeth od>, I have to
              manually enter the column names for the ID and value. How do I make
              the schema available?
              >
              ObjectDataSourc es do not present database schema information at Design
              Time in the same way as SQl or XML sources. The output from code
              behind ObjectDatasourc es 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.




              Comment

              • Larry Bud

                #8
                Re: Retrieving ObjectDataSourc e columns

                On Oct 17, 2:14 pm, Poli García <poligar...@gma il.comwrote:
                Larry Bud wrote:
                On Oct 17, 11:44 am, Poli García <poligar...@gma il.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 <dataobjectmeth od>, 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
                datasourceobjec t, 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 AutoGenerateCol umns 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.

                Comment

                Working...