Hello,
I have a basic Grid composed with one GridDropDownColumn.
The grid is filled through ObjectdataSource1 :
The SelectMethod returns a generic List of Week:
The DropDownColum is filled through ObjectDataSource2:
The SelectMethod returns a generic List of Day:
The Grid is configured like that:
The Week class is defined like that :
and the Day class :
The values are correctly displayed in both Grid and DropdownList. The problem is during the update phase.
The Update method of the ObjectDataSource1 is defined like that:
The selected value of the Dropdownlist ("Code" property of the Day object) is not saved in the database. It seems there is "no link" between RadGrid and Dropdowlist controls. What is the best practise to link a GridDropDownColumn Value in a RadGridView Using ObjectDataSource (one for Dropdownlist and one for Gridview) ?
Thanks for your support.
Regards,
Stephane
I have a basic Grid composed with one GridDropDownColumn.
The grid is filled through ObjectdataSource1 :
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" OnSelecting="ObjectDataSource1_Selecting" SelectMethod="select_AllWeek" TypeName="Planning.WeekDAL" DataObjectTypeName="Planning.Week" UpdateMethod="update_Week"> <SelectParameters> <asp:Parameter Name="IdFrame" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource>The SelectMethod returns a generic List of Week:
[DataObjectMethod(DataObjectMethodType.Select)] public static List<Week> select_AllWeek(int IdFrame) {...}The DropDownColum is filled through ObjectDataSource2:
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="select_Alldays" TypeName="Planning.DayDAL"></asp:ObjectDataSource>The SelectMethod returns a generic List of Day:
[DataObjectMethod(DataObjectMethodType.Select)] public static List<Day> select_AllDays() { ....}The Grid is configured like that:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1"> <MasterTableView DataSourceID="ObjectDataSource1" EditMode="InPlace"> <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn AllowFiltering="False" AllowSorting="False" Groupable="False" HeaderText="Week" UniqueName="Week" DataField="Libelle"> </telerik:GridBoundColumn> <telerik:GridDropDownColumn DataSourceID="ObjectDataSource2" ListTextField="Code" ListValueField="Id" DataField="Monday.Id" UniqueName="Monday" HeaderText="Monday" FooterStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" AllowFiltering="False" AllowSorting="False" Groupable="False"> </telerik:GridDropDownColumn> <telerik:GridBoundColumn AllowFiltering="False" AllowSorting="False" Groupable="False" HeaderText="Tuesday" UniqueName="Tuesday" DataField="Tuesday.Code"> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn> </telerik:GridEditCommandColumn> </Columns> <EditFormSettings> <EditColumn UniqueName="EditCommandColumn1"> </EditColumn> </EditFormSettings> </MasterTableView> <HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default"> </HeaderContextMenu> </telerik:RadGrid>The Week class is defined like that :
public class Week: IEnumerable
{ #region Fields protected List<Day> Days= new List<Day>(); private int _id; ...
# region properties
public Day Monday
{
get{return Days[0];}
set{Days[0] = value;}
}
and the Day class :
public class Day { #region Fields private int _id; private string _code; ... #endregion #region Properties public int Id { get { return _id; } set { _id = value; } } public string Code { get {return _code;} set { _code = value;} } ... ]The values are correctly displayed in both Grid and DropdownList. The problem is during the update phase.
The Update method of the ObjectDataSource1 is defined like that:
[DataObjectMethod(DataObjectMethodType.Update)] public static void update_Week(Week oneweek) { PrepareConnexion(); connexion.Open(); ... The selected value of the Dropdownlist ("Code" property of the Day object) is not saved in the database. It seems there is "no link" between RadGrid and Dropdowlist controls. What is the best practise to link a GridDropDownColumn Value in a RadGridView Using ObjectDataSource (one for Dropdownlist and one for Gridview) ?
Thanks for your support.
Regards,
Stephane