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

Problem in Rad combobox

1 Answer 51 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mugil
Top achievements
Rank 1
Mugil asked on 20 Mar 2013, 09:56 PM
Hi


        when i filter the radgrid using rad combobox its filtering
        but problem is in the after getting filter in the radcombobox the value binded in two time

        for ur clarrification i just attached two diiferent files pls refer it and give the solution




Regards
P.Mugil

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Mar 2013, 04:37 AM
Hi,

It is very difficult to replicate the issue without inspecting the code. Please take a look into the following code snippet I tried to Filter a field using RadComboBox.

ASPX:
<telerik:RadGrid ID="RadGridFilter" runat="server" OnItemDataBound="RadGridFilter_ItemDataBound"
    OnNeedDataSource="RadGridFilter_NeedDataSource" AllowFilteringByColumn="true"
    EnableLinqExpressions="false">
    <MasterTableView>
        <Columns>
            <telerik:GridBoundColumn DataField="OrderID" HeaderText="OrderID" SortExpression="OrderID"
                UniqueName="OrderID">
                <FilterTemplate>
                    <telerik:RadComboBox runat="server" ID="FilterCombo" AutoPostBack="true" OnSelectedIndexChanged="FilterCombo_SelectedIndexChanged">
                    </telerik:RadComboBox>
                </FilterTemplate>
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void RadGridFilter_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    string selectQuery1 = "select top 10 OrderID from Orders";
    SqlDataAdapter adapter1 = new SqlDataAdapter(selectQuery1, conn);
    conn.Open();
    adapter1.Fill(dt1);
    conn.Close();
    RadGridFilter.DataSource = dt1;       
}
protected void RadGridFilter_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridFilteringItem)
    {
        GridFilteringItem Fitem = (GridFilteringItem)e.Item;
        RadComboBox FilterCombo = (RadComboBox)Fitem.FindControl("FilterCombo");
        FilterCombo.DataSource = dt1;
        FilterCombo.DataTextField = "OrderID";
        FilterCombo.DataValueField = "OrderID";
        FilterCombo.DataBind();
    }
}
protected void FilterCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
    string filterExpression;
    filterExpression = "([OrderID] = '" + e.Value + "')";
    RadGridFilter.MasterTableView.FilterExpression = filterExpression;
    RadGridFilter.MasterTableView.Rebind();
}

Please elaborate the scenario or provide the code if it doesn't help.

Thanks,
Shinu.
Tags
General Discussions
Asked by
Mugil
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or