This is a migrated thread and some comments may be shown as answers.

dropdownlist grid column

1 Answer 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 24 Nov 2009, 04:28 PM
Hi,
  we have a griddropdowncolumn in our grid, however I want to set the selected value of the dropdownlist to the selected value of an
drop down list of the form called ddl_dayDate. Any ideas how to do this?



        <telerik:GridDropDownColumn  FilterControlWidth="250px"
        DataField = "day_date_id" DataSourceID="sql_daydate_all"
            HeaderText="day date" ListTextField="day_date_ref" ListValueField="id"
            UniqueName="day_date_id" ColumnEditorID="DropDownColumnEditor1">
           
             <HeaderStyle Width="160px" />
              <FilterTemplate>
                            <telerik:RadComboBox ID="RadComboBoxTitle" DataSourceID="sql_daydate_all" DataTextField="day_date_ref"
                                DataValueField="id"  AppendDataBoundItems="true"
                              SelectedValue='<%#  ((GridItem)Container).OwnerTableView.GetColumn("day_date_id").CurrentFilterValue %>'
                              
                                runat="server" OnClientSelectedIndexChanged="DayDateIndexChanged">
                                <Items>
                                    <telerik:RadComboBoxItem Text="All" />
                                </Items>
                            </telerik:RadComboBox>
                            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                                <script type="text/javascript">
                                    function DayDateIndexChanged(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("day_date_id", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>

                            </telerik:RadScriptBlock>
                        </FilterTemplate>
        </telerik:GridDropDownColumn>

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Nov 2009, 05:19 AM
Hi Robert Smith,

You can access the combobox for the dropdowncolumn and populate it based on the selection in the dropdownlist, outside the grid. Check out the example below:

cs:
 
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            RadComboBox combo = (RadComboBox)editItem["day_date_id"].Controls[0]; 
            combo.SelectedValue = ddl_dayDate.SelectedValue; 
        } 
    } 

-Shinu.
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or