Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
dropdownlist column won't save value to database
posted

I have a simple WebGrid with an Int32 column I set to a dropdownlist.  I have the dropdown list referencing an ObjectDataSource as follows:

WebGrid Column

Type:   DropDownList
BaseColumnName:  ClientID
DataType:   System.Int32
Key:   ClientID

 

ValueList:

DataMember:    (blank since I'm using an ObjectDataSource which creates it's own dataview)
DataSourceID:    dsClients
DisplayMember:  Description
DisplayStyle:       DisplayText
Key:   ClientID
ValueMember:   ClientID

 

Everything seems to work fine at first.  ClientID ints in the database properly display as client name strings in the column.  I can doubleclick the cell to show the dropdown and select from client name strings.  This would imply the datatypes match between column and dropdownlist, right?

But when I save either through UpdateRow ajax or a postback, this column saves a NULL into the database.   Every other grid column saves fine, so updating works.   Oddly, if I set DisplayStyle in the ValueList to DataValue, it will save my selection, but then the dropdown list only shows the ClientIDs (i.e. numbers).  In other words, I can get it to correctly display the client names based on original database ints, but it just won't save an int back to the database.

Thanks for any ideas.

Jim

Parents
No Data
Reply
  • 8680
    posted

    Based upon your description, I don't see what the problem is, but in the past, I've solved dropdown problems by checking:

    • Is the column.ColumnType set to DropDownList?
    • Do the data types match?  Datatypes for the underlying row data (in your database) need to match those in the database data destined for the dropdown's ValueList.ValueMember. In the grid, the UltraGridColumn.DataType must also match.
    • Do the column names match?  (In all the same places.)

    We might be more likely to spot your problem if you post your markup and code.

Children