access rad combobox inside the griddropdowncolumn

3 posts, 0 answers
  1. Richard
    Richard avatar
    8 posts
    Member since:
    Oct 2012

    Posted 19 Jun 2013 Link to this post

    how di programitaccly acces the DataSource property of a RadComboBox that is in the Filtertemplate of a GridDropdownColumn of my grid
    I want to set the datasource in code behind at the server side

    							<telerik:GridDropDownColumn DataField="ProductVolumeID" DataSourceID="ProductVolumeDataSource"
    									HeaderText="Product Volume" ListTextField="LongDesc" ListValueField="ProductVolumeID"
    									UniqueName="ProductVolumeID">
    									<FilterTemplate>
    											<telerik:RadComboBox ID="ProductVolumeComboBox" DataSourceID="ProductVolumeDataSource" DataTextField="LongDesc"
    													DataValueField="ProductVolumeID" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("ProductVolumeID").CurrentFilterValue %>'
    													runat="server" OnClientSelectedIndexChanged="ProductVolumeIndexChanged">
    													<Items>
    															<telerik:RadComboBoxItem Text="All" />
    													</Items>
    											</telerik:RadComboBox>
    											<telerik:RadScriptBlock ID="ProductVolumeIndexChangedRadScriptBlock" runat="server">
    													<script type="text/javascript">
                            		function ProductVolumeIndexChanged(sender, args) {
    															var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
    															tableView.filter("ProductVolumeID", args.get_item().get_value(), "StartsWith");
    														}
    													</script>
    											</telerik:RadScriptBlock>
    									</FilterTemplate>
    							</telerik:GridDropDownColumn>
    
    How do i programitaccly access the DataSource property of a RadComboBox that is in the FilterTemplate of a GridDropDownColumn
    I want to set the datasource in the server side code and not use the DataSourceID
      
                                <telerik:GridDropDownColumn DataField="ProductVolumeID" DataSourceID="ProductVolumeDataSource"
                                        HeaderText="Product Volume" ListTextField="LongDesc" ListValueField="ProductVolumeID"
                                        UniqueName="ProductVolumeID">
                                        <FilterTemplate>
                                                <telerik:RadComboBox ID="ProductVolumeComboBox" DataSourceID="ProductVolumeDataSource" DataTextField="LongDesc"
                                                        DataValueField="ProductVolumeID" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("ProductVolumeID").CurrentFilterValue %>'
                                                        runat="server" OnClientSelectedIndexChanged="ProductVolumeIndexChanged">
                                                        <Items>
                                                                <telerik:RadComboBoxItem Text="All" />
                                                        </Items>
                                                </telerik:RadComboBox>
                                                <telerik:RadScriptBlock ID="ProductVolumeIndexChangedRadScriptBlock" runat="server">
                                                        <script type="text/javascript">
                                    function ProductVolumeIndexChanged(sender, args) {
                                                                var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                                                tableView.filter("ProductVolumeID", args.get_item().get_value(), "StartsWith");
                                                            }
                                                        </script>
                                                </telerik:RadScriptBlock>
                                        </FilterTemplate>
                                </telerik:GridDropDownColumn>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Jun 2013 Link to this post

    Hi Richard,

    Try the following code snippet.

    C#:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
      if (e.Item is GridFilteringItem)
       {
          GridFilteringItem filterItem = (GridFilteringItem)e.Item;
          RadComboBox combo = (RadComboBox)filterItem["colUniquename"].FindControl("RadComboBox1");//accessing combobox
          DataTable dt1 = (DataTable)Session["dt"];
          combo.DataSource = dt1; // setting datasource
          combo.DataTextField = "CustomerID";
          combo.DataValueField = "CustomerID";
          combo.DataBind();
       
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Richard
    Richard avatar
    8 posts
    Member since:
    Oct 2012

    Posted 20 Jun 2013 Link to this post

    Duh, how did i miss that?
    Works just fine thanks
Back to Top