in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

ASPxComboBox Databinding to GUID

Last post 11/14/2008 3:46 PM by Mehul Harry (Developer Express). 9 replies.
Page 1 of 1 (10 items)
Sort Posts:
Previous Next
  • 10/11/2007 8:47 AM

    ASPxComboBox Databinding to GUID

     

    Hi!

    I’m trying to bind a ComboBox to an ObjectDataSource where the Id field is a GUID.

                ValueField = Id --> GUID

                TextField = Name --> String
     

    I get this error: “System.InvalidCastException: Object must implement IConvertible.”


    But when I have previously used the ASPxGridView and the GridViewDataComboBoxColumn

    I have no problem binding to GUID field.

      

    I use ASPxGridView and Editors library v. 7.2.4

    Can anyone please provide me with a workaround for this problem?

     

    Thanks!

     

    Filed under: , ,
  • 10/12/2007 6:16 AM In reply to

    Re: ASPxComboBox Databinding to GUID

    Answer

    Hello Magne,

    Yes, I'm able to reproduce this as well. We'll look into it but in the meantime time, try the following workaround. Instead of a combo box column, use an ASPxComboBox in the EditItemTemplate and then set the ValueType to System.Guid. It's not an option but it does work:

        <dxwgv:GridViewDataTextColumn Caption="combocolumn" VisibleIndex="7">
            <EditItemTemplate>
                <dxe:ASPxComboBox ID="ASPxComboBox1" runat="server" DataSourceID="ObjectDataSource2"
                    TextField="FirstName" ValueField="Guid" ValueType="System.Guid">
                </dxe:ASPxComboBox>
            </EditItemTemplate>
        </dxwgv:GridViewDataTextColumn>

    Thanks.

    Filed under:
  • 10/16/2007 7:00 PM In reply to

    Re: ASPxComboBox Databinding to GUID

    Hello Magne,

    The solution is to make sure the column is bound to a Guid field in both tables:

                    <dxwgv:GridViewDataComboBoxColumn Caption="combocol" VisibleIndex="7" FieldName="Guid">
                        <PropertiesComboBox DataSourceID="ObjectDataSource2" TextField="FirstName" ValueField="Guid" ValueType="System.Guid">
                        </PropertiesComboBox>
                    </dxwgv:GridViewDataComboBoxColumn>

    Thanks.

    Filed under:
  • 4/22/2008 4:32 AM In reply to

    • Roy Venema
    • Not Ranked
    • Joined on 6/22/2007
    • The Netherlands
    • Posts 4

    Re: ASPxComboBox Databinding to GUID

    Hi,

    I have an aspxcombobox inside a formview. The combobox keeps displaying the GUID instead of the textvalue. Unfortunately there is no fieldname property in the formview.
    Is there a way to get this working inside a formview?

    Thanks
    Roy

     Note: anyone who has trouble inserting or updating GUID fields: remove the part <type="object">  from the insert or update parameters for the GUID column.

      

     

     

  • 4/22/2008 6:54 PM In reply to

    Re: ASPxComboBox Databinding to GUID

    Hello Roy,

    If you manually set the textfield and valuefield in the aspx source then it should work fine:

          <asp:FormView ID="FormView1" Runat="server" DataSourceID="SqlDataSource1"
            HeaderText="Customers" AllowPaging="True" DataKeyNames="AddressID">
              <EditItemTemplate>
                  AddressID:
                  <asp:Label ID="AddressIDLabel1" runat="server" 
                      Text='<%# Eval("AddressID") %>' />
                  <br />
                  City:
                  <asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
                  <br />
                  StateProvince:
                  <asp:TextBox ID="StateProvinceTextBox" runat="server" 
                      Text='<%# Bind("StateProvince") %>' />
                  <br />
                  rowguid:
                  <asp:TextBox ID="rowguidTextBox" runat="server" Text='<%# Bind("rowguid") %>' />
                  <br />
                  <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                      CommandName="Update" Text="Update" />
                  &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                      CausesValidation="False" CommandName="Cancel" Text="Cancel" />
              </EditItemTemplate>
              <InsertItemTemplate>
                  City:
                  <asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
                  <br />
                  StateProvince:
                  <asp:TextBox ID="StateProvinceTextBox" runat="server" 
                      Text='<%# Bind("StateProvince") %>' />
                  <br />
                  rowguid:
                  <asp:TextBox ID="rowguidTextBox" runat="server" Text='<%# Bind("rowguid") %>' />
                  <br />
                  <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                      CommandName="Insert" Text="Insert" />
                  &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                      CausesValidation="False" CommandName="Cancel" Text="Cancel" />
              </InsertItemTemplate>
            <ItemTemplate>
                AddressID:
                <asp:Label ID="AddressIDLabel" runat="server" Text='<%# Eval("AddressID") %>' />
                <br />
                City:
                <asp:Label ID="CityLabel" runat="server" Text='<%# Bind("City") %>' />
                <br />
                StateProvince:
                <asp:Label ID="StateProvinceLabel" runat="server" 
                    Text='<%# Bind("StateProvince") %>' />
                <br />
                rowguid:
                <asp:Label ID="rowguidLabel" runat="server" Text='<%# Bind("rowguid") %>' />
                <br />
                <dxe:ASPxComboBox ID="ASPxComboBox2" runat="server" 
                    DataSourceID="SqlDataSource1" ValueType="System.String" 
              TextField="AddressID" ValueField="rowguid">
                </dxe:ASPxComboBox>
            </ItemTemplate>
          </asp:FormView>
                <br />
                <dxe:ASPxComboBox ID="ASPxComboBox2" runat="server" 
                    DataSourceID="SqlDataSource1" ValueType="System.String" 
              TextField="AddressID" ValueField="rowguid">
                </dxe:ASPxComboBox>
                <br />
     
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
              ConnectionString="<%$ ConnectionStrings:AdventureWorksLTConnectionString %>" 
              SelectCommand="SELECT [AddressID], [City], [StateProvince], [rowguid] FROM [SalesLT].[Address]">
          </asp:SqlDataSource>
         </form>

     

    Thanks.

  • 4/24/2008 2:01 PM In reply to

    Re: ASPxComboBox Databinding to GUID

     Mehul....that's not a good example.

     You are binding the main field to be populated in the combobox by the keyid in the header of the formview.

     I'd like to have a formview on table A and have a combo box referencing a secondary key from table B.

    It would appear that the DEVX combobox component was designed to work well with your grid component but there was little consideration about putting it as a standalone control in a formview where the text and value property fields differ.

  • 4/24/2008 3:55 PM In reply to

    Re: ASPxComboBox Databinding to GUID

    Hello Sean,

    You can reference 2 fields from 2 tables. You should consider the relationship between them first. There must be some 1:1 relation between them.

    In any case, this isn't a limitation of the ASPxComboBox. You would only need to setup the proper sql and/or datasource and then select these values in the TextField and ValueField of the ASPxComboBox. You'll find this works the same in the Microsoft control as well.

    If I've misunderstood you, I apologize and I'll simply ask if you can post a more detailed scenario as well some sample code and I'll be happy to try to help you.

    Thanks.

     

    Filed under:
  • 4/25/2008 2:00 PM In reply to

    Re: ASPxComboBox Databinding to GUID

     

     Hi Mehul,

    Just to clarify, there is one formview and two sqldatasources (sales and customers).

    The formview is bound to sales. 

    A standard Microsoft dropdownlist bound to sales.customer_pk with Datatextfield
    set to customers.name and Datavaluefield set to customers.customer_pk works.

    Using the ASPxCombobox, bind to sales.customer_pk, valuefield is customers.customer_pk, textfield is customers.name.

    This doesn't work.

    The ASPxCombobox saves the correct value into sales ok, but when I call the screen back up it displays customer_pk for the text
    instead of the customers.name.

    Hope that clarifies it.

     

  • 11/14/2008 3:20 PM In reply to

    Re: ASPxComboBox Databinding to GUID

    I am also confirming this guid related bug.

    There is definitely a problem regarding having a comobox with text value of something (eg text) and value field of guid.

    My update/insert/delete works fine, but after I insert the row, the text value is not displayed, but guid value.

    With integer or something else, this works perfectly, but unfortunately I am bound to guid and would like to see this finally fixed, since it's been almost a year since you have received this bug info.

  • 11/14/2008 3:46 PM In reply to

    Re: ASPxComboBox Databinding to GUID

    Hi Boris,

    Please report issue to the support center with a sample app so the team can verify and fix the issue.

Page 1 of 1 (10 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED