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

Data binding of filter combo programatically

3 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saima Gul
Top achievements
Rank 1
Saima Gul asked on 27 Mar 2010, 08:43 AM
Hi
i see this demo to use combo for filteration in grid

but i dnt want to bind it with SQLDataSource but instead want to bind combo used for filteration programatically. i try Grid ItemDatabound event for this but it returns error. Which event of grid is used for doing this and how can i do so?






3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 29 Mar 2010, 11:05 AM
Hello Saima,

For more information about how to achieve your goal, please refer to the following forum thread:
RadComboBox in GridTemplateColumn

Additionally, I suggest you review the help article below:
Databinding Overview

Regards,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Saima Gul
Top achievements
Rank 1
answered on 30 Mar 2010, 08:36 AM
Thanks for responding but it can not help me out. i am not using Grid Template column what i am using is
<telerik:RadGrid ID="grdDefList" runat="server" AllowFilteringByColumn="True" AllowPaging="True" Width="370px"
        AllowAutomaticDeletes="true" PageSize="15" PagerStyle-AlwaysVisible="true" PagerStyle-ShowPagerText="false"
        AllowSorting="True" AutoGenerateColumns="False" GridLines="None" 
        OnNeedDataSource="grdDefList_NeedDataSource"
OnItemDataBound="grdDefList_ItemDataBound"
        >
        <PagerStyle AlwaysVisible="True" ShowPagerText="False"></PagerStyle>
        <MasterTableView AutoGenerateColumns="false" ShowHeadersWhenNoRecords="true" Width="100%">
            <Columns>
                <telerik:GridBoundColumn DataField="AccountNo" HeaderText="A/c No" 
                    ShowFilterIcon="false" FilterControlWidth="30px" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="40px" />
                </telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="AccountTypeName" UniqueName="AccountTypeName"  HeaderText="Type" 
                    ShowFilterIcon="false" FilterControlWidth="90px" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                    <HeaderStyle Width="100px" />
                    <FilterTemplate>
                        <telerik:RadComboBox ID="cmbFilAccType" runat="server" Width="80px" AppendDataBoundItems="true" 
                            DataTextField="AccountTypeName" DataValueField="AccountTypeName" 
                            CloseDropDownOnBlur="true" 
                            SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("AccountTypeName").CurrentFilterValue %>'                            
                            OnClientSelectedIndexChanged="SelectedIndexChanged">
                        <Items>
                        <telerik:RadComboBoxItem Text="" Value="" Selected="true" />
                        </Items>
                            
                        </telerik:RadComboBox> 
                        
                    </FilterTemplate>
                </telerik:GridBoundColumn>
</Columns>
        </MasterTableView>
</telerik:RadGrid>

My Code behind file is using this
protected void grdDefList_ItemDataBound(object source, GridItemEventArgs e)
        {
            if (e.Item is GridFilteringItem)
            {
                RadComboBox cmbFilAccType = (RadComboBox)e.Item.FindControl("cmbFilAccType");
                if (cmbFilAccType != null)
                {
                    string query="Select AccountTypeId,AccountTypeName from AccAccountTypes order by AccountTypeName";
    DataTable myDataTable=getDataTable(query);
                    cmbFilAccType.DataSource = myDataTable;
                    cmbFilAccType.DataBind();
                }
            }
        }
So it returns me error

This row has been removed from a table and does not have any data.  BeginEdit() will allow creation of new data in this row.



So please tell me how can i get required functionality
0
Pavlina
Telerik team
answered on 01 Apr 2010, 04:00 PM
Hello Saima,

Please, go through the following forum thread, which elaborates on this matter and let me know if the issue still persists:
http://www.telerik.com/community/forums/aspnet-ajax/grid/filter-template-inside-boundcolumn-in-radgrid.aspx

Kind regards,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Saima Gul
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Saima Gul
Top achievements
Rank 1
Share this question
or