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

[Solved] set dynamic datasource for dropdownlist in RadGrid

1 Answer 248 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark asked on 25 Nov 2009, 02:07 PM
Hi,
   I have a RadGrid with a combobox column with filter (see below). However I wish to set the datasource of the combobox with a specific
parameter, so that I can use the same datasource for different columns in the grid with different parameters

Say that the Datasource is  as sqldatasource called sql_baselines and the parameter is day_id how do I set the datasource
for day_id = 1

Thanks in advance

Robert

</telerik:GridBoundColumn>
        <telerik:GridDropDownColumn  FilterControlWidth="250px"
        DataField = "monday" DataSourceID="sql_baselines_monday"
            HeaderText="monday" ListTextField="shift" ListValueField="BaseLineId"
            UniqueName="monday" ColumnEditorID="DropDownColumnEditor1">
           
             <HeaderStyle Width="160px" />
              <FilterTemplate>
                            <telerik:RadComboBox ID="RadComboBoxDayDate" DataSourceID="sql_baselines_monday" DataTextField="shift"
                                DataValueField="BaselineId"  AppendDataBoundItems="true"
                              SelectedValue='<%#  ((GridItem)Container).OwnerTableView.GetColumn("monday").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("monday", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>

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

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 30 Nov 2009, 06:58 AM
Hi Robert,

The datasource can be declared in the filter template directly, or on the page. Depending on where you declare it, you will or will not have visibility to the combo. For example, if the datasource is declared as part of the fitler template, you will be able to specify the combo as a select parameter, whereas, if it is not, you may not have visibility to the combo.
Additionally, what other controls on the page will be using the same datasource?

Greetings,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Answers by
Yavor
Telerik team
Share this question
or