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

access rad combobox inside the griddropdowncolumn

2 Answers 98 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 19 Jun 2013, 08:01 PM

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 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Jun 2013, 04:30 AM
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.
0
Richard
Top achievements
Rank 1
answered on 20 Jun 2013, 12:34 PM
Duh, how did i miss that?
Works just fine thanks
Tags
DropDownList
Asked by
Richard
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Richard
Top achievements
Rank 1
Share this question
or