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: DropDownListBaseColumnName: ClientIDDataType: System.Int32Key: ClientID
ValueList:
DataMember: (blank since I'm using an ObjectDataSource which creates it's own dataview)DataSourceID: dsClientsDisplayMember: DescriptionDisplayStyle: DisplayTextKey: ClientIDValueMember: 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
Based upon your description, I don't see what the problem is, but in the past, I've solved dropdown problems by checking:
We might be more likely to spot your problem if you post your markup and code.
Below is the markup code. Included are the three objects, the grid, main datasource, and dropdownlist datasource.Since updates are automatic, there isn't any C# code-behind to show.I bolded the dropdown column that refuses to update. Always returns "0" in RowUpdate.
Thanks for any help -Jim
<!-- GRID --> <igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" Browser="Xml" DataKeyField="StudyID, ScenarioID" DataSourceID="ObjectDataSource2" Height="313px" OnUpdateRow="UltraWebGrid1_UpdateRow" Width="854px"> <Bands> <igtbl:UltraGridBand AddButtonCaption="Studies" BaseTableName="Studies" DataKeyField="StudyID, ScenarioID" Key="Studies"> <Columns> <igtbl:UltraGridColumn BaseColumnName="StudyID" IsBound="True" Key="StudyID" Width="75px"> <Header Caption="StudyID"> </Header> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="ScenarioID" DataType="System.Int32" Format="####" IsBound="True" Key="ScenarioID" Width="55px"> <Header Caption="Scenario"> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn AllowUpdate="Yes" BaseColumnName="ClientID" DataType="System.Int32" IsBound="True" Key="ClientID" Type="DropDownList" Width="65px"> <ValueList DataSourceID="dsClients" DisplayMember="Description" Key="ClientID" ValueMember="ClientID"> </ValueList> <Header Caption="Client"> <RowLayoutColumnInfo OriginX="2" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="2" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="Description" IsBound="True" Key="Description"> <Header Caption="Study Name"> <RowLayoutColumnInfo OriginX="3" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="3" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="Comments" HTMLEncodeContent="True" IsBound="True" Key="Comments" Width="130px"> <Header Caption="Comments"> <RowLayoutColumnInfo OriginX="4" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="4" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn AllowUpdate="No" BaseColumnName="LastUpdated" DataType="System.DateTime" Format="yyyy-MM-dd hh:mm" IsBound="True" Key="LastUpdated"> <Header Caption="LastUpdated"> <RowLayoutColumnInfo OriginX="5" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="5" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="XMLDataSet" Hidden="True" IsBound="True" Key="XMLDataSet"> <Header Caption="XMLDataSet"> <RowLayoutColumnInfo OriginX="6" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="6" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="UserID" DataType="System.Int32" Hidden="True" IsBound="True" Key="UserID"> <Header Caption="UserID"> <RowLayoutColumnInfo OriginX="7" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="7" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="LockStatus" DataType="System.Boolean" IsBound="True" Key="LockStatus" Type="CheckBox" Width="55px"> <Header Caption="Locked"> <RowLayoutColumnInfo OriginX="8" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="8" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="LockTimeStamp" DataType="System.DateTime" Format="yyyy-MM-dd hh:mm" IsBound="True" Key="LockTimeStamp"> <Header Caption="LockTimeStamp"> <RowLayoutColumnInfo OriginX="9" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="9" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn BaseColumnName="Status" DataType="System.Int32" IsBound="True" Key="Status" Width="50px"> <Header Caption="Status"> <RowLayoutColumnInfo OriginX="10" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="10" /> </Footer> </igtbl:UltraGridColumn> </Columns> <AddNewRow Visible="Yes"> </AddNewRow> </igtbl:UltraGridBand> </Bands> <DisplayLayout AllowAddNewDefault="Yes" AllowSortingDefault="OnClient" AllowUpdateDefault="Yes" BorderCollapseDefault="Separate" CellClickActionDefault="Edit" HeaderClickActionDefault="SortSingle" LoadOnDemand="Xml" Name="UltraWebGrid1" RowHeightDefault="20px" RowSelectorsDefault="No" SelectTypeRowDefault="Single" StationaryMargins="Header" StationaryMarginsOutlookGroupBy="True" TableLayout="Fixed" Version="4.00"> <FrameStyle BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid" BorderWidth="1px" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Height="313px" Width="854px"> </FrameStyle> <Pager MinimumPagesForDisplay="2"> <PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" /> </PagerStyle> </Pager> <EditCellStyleDefault BorderStyle="None" BorderWidth="0px"> </EditCellStyleDefault> <FooterStyleDefault BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" /> </FooterStyleDefault> <HeaderStyleDefault BackColor="#009DD9" BorderStyle="Solid" ForeColor="White" HorizontalAlign="Left"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" /> </HeaderStyleDefault> <RowStyleDefault BackColor="Window" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt"> <Padding Left="3px" /> <BorderDetails ColorLeft="Window" ColorTop="Window" /> </RowStyleDefault> <GroupByRowStyleDefault BackColor="Control" BorderColor="Window"> </GroupByRowStyleDefault> <GroupByBox> <BoxStyle BackColor="ActiveBorder" BorderColor="Window"> </BoxStyle> </GroupByBox> <AddNewBox Hidden="False" Prompt="Add New Row"> <BoxStyle BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid" BorderWidth="1px"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" /> </BoxStyle> </AddNewBox> <ActivationObject BorderColor="" BorderWidth=""> </ActivationObject> <AddNewRowDefault Visible="Yes"> </AddNewRowDefault> <FilterOptionsDefault> <FilterDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Size="11px" Height="300px" Width="200px"> <Padding Left="2px" /> </FilterDropDownStyle> <FilterHighlightRowStyle BackColor="#151C55" ForeColor="White"> </FilterHighlightRowStyle> <FilterOperandDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Size="11px"> <Padding Left="2px" /> </FilterOperandDropDownStyle> </FilterOptionsDefault> </DisplayLayout> </igtbl:UltraWebGrid> </p>
<!-- MAIN DATASOURCE --> <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetStudies" TypeName="BASES.DataCollection.DecisionPoint.DPDesigner.DPDesignerDSTableAdapters.StudiesTableAdapter" UpdateMethod="Update" OldValuesParameterFormatString="original_{0}" DeleteMethod="Delete" InsertMethod="Insert"> <DeleteParameters> <asp:Parameter Name="Original_StudyID" Type="String" /> <asp:Parameter Name="Original_ScenarioID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="StudyID" Type="String" /> <asp:Parameter Name="ScenarioID" Type="Int32" /> <asp:Parameter Name="ClientID" Type="Int32" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Comments" Type="String" /> <asp:Parameter Name="LastUpdated" Type="DateTime" /> <asp:Parameter Name="XMLDataSet" Type="Object" /> <asp:Parameter Name="UserID" Type="Int32" /> <asp:Parameter Name="LockStatus" Type="Boolean" /> <asp:Parameter Name="LockTimeStamp" Type="DateTime" /> <asp:Parameter Name="Status" Type="Int32" /> <asp:Parameter Name="Original_StudyID" Type="String" /> <asp:Parameter Name="Original_ScenarioID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="StudyID" Type="String" /> <asp:Parameter Name="ScenarioID" Type="Int32" /> <asp:Parameter Name="ClientID" Type="Int32" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Comments" Type="String" /> <asp:Parameter Name="LastUpdated" Type="DateTime" /> <asp:Parameter Name="XMLDataSet" Type="Object" /> <asp:Parameter Name="UserID" Type="Int32" /> <asp:Parameter Name="LockStatus" Type="Boolean" /> <asp:Parameter Name="LockTimeStamp" Type="DateTime" /> <asp:Parameter Name="Status" Type="Int32" /> </InsertParameters> </asp:ObjectDataSource> <!-- DROPDOWNLIST DATASOURCE --> <asp:ObjectDataSource ID="dsClients" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="BASES.DataCollection.DecisionPoint.DPDesigner.DPDesignerDSTableAdapters.ClientsTableAdapter" UpdateMethod="Update"> <DeleteParameters> <asp:Parameter Name="Original_ClientID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="BASESAnswersGroupID" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Comments" Type="String" /> <asp:Parameter Name="Original_ClientID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="ClientID" Type="Int32" /> <asp:Parameter Name="BASESAnswersGroupID" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Comments" Type="String" /> </InsertParameters> </asp:ObjectDataSource>