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

GridDateTimeColumn not filtering w LinqDataSource and onselecting

2 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roelf
Top achievements
Rank 1
Roelf asked on 02 Mar 2015, 07:12 AM
Hi

I am trying to use a rad grid with a linqdatasource, but because we are using webapi calls we cannot directly bind to the database. The filter does not work correctly and the datetime picker does not remember the value after the postback occurs.

Here is the ASP:

<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPag="True" DataSourceID="LinqDataSource1" GroupPanelPosition="Top">
       <MasterTableView AutoGenerateColumns="False" DataKeyNames="TaskID" DataSourceID="LinqDataSource1">
           <Columns>
               <telerik:GridDateTimeColumn DataField="DateCreated" DataType="System.DateTime" EnableTimeIndependentFiltering="true" FilterControlAltText="Filter DateCreated column" HeaderText="DateCreated" SortExpression="DateCreated" UniqueName="DateCreated" ShowFilterIcon="false" AutoPostBackOnFilter="true">
                   <ColumnValidationSettings>
                       <ModelErrorMessage Text="" />
                   </ColumnValidationSettings>
               </telerik:GridDateTimeColumn>
           </Columns>
       </MasterTableView>
   </telerik:RadGrid>
   <asp:LinqDataSource ID="LinqDataSource1" OnSelect
        
       ing="LinqDataSource1_Selecting" runat="server">
   </asp:LinqDataSource>

And the codebehind:

public partial class Test : System.Web.UI.Page
    {
        private WebAPICalls MyWebAPi = new WebAPICalls();
 
        protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            var tasks = MyWebAPi.GetDataTable("GetAllTasks");
            //Doing this otherwise it complains about not finding the TaskID property
            var results = from rows in tasks.AsEnumerable()
                          select rows;
            e.Result = results;
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
        }
    }

Thanks

2 Answers, 1 is accepted

Sort by
0
Roelf
Top achievements
Rank 1
answered on 02 Mar 2015, 07:15 AM
Apologies, there is a an extra carriage return on the asp code, here it is again:

<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPag="True" DataSourceID="LinqDataSource1" GroupPanelPosition="Top">
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="TaskID" DataSourceID="LinqDataSource1">
            <Columns>
                <telerik:GridDateTimeColumn DataField="DateCreated" DataType="System.DateTime" EnableTimeIndependentFiltering="true" FilterControlAltText="Filter DateCreated column" HeaderText="DateCreated" SortExpression="DateCreated" UniqueName="DateCreated" ShowFilterIcon="false" AutoPostBackOnFilter="true">
                    <ColumnValidationSettings>
                        <ModelErrorMessage Text="" />
                    </ColumnValidationSettings>
                </telerik:GridDateTimeColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:LinqDataSource ID="LinqDataSource1" OnSelecting="LinqDataSource1_Selecting" runat="server">
    </asp:LinqDataSource>
0
Angel Petrov
Telerik team
answered on 05 Mar 2015, 07:09 AM
Hi,

Generally you should not experience such behavior and the picker value should persist. Could you please share with us the entire page contents(markup and code-behind) so we could examine the implementation?
Additionally please try reproducing the problem on our online demos site and let us know if you are able to do so.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Roelf
Top achievements
Rank 1
Answers by
Roelf
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or