I've found a strange behavior with Telerik RadGrid Datasource using Microsoft LINQ To Sql, which I'd like to know what reason causes it.
Suppose I've a basic grid with OnNeedDataSource event:
<telerik:RadGrid ID="grid" runat="server" OnNeedDataSource="grid_NeedDataSource">
...
</telerik:RadGrid>
Event handler in code-behind:
protected void grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
grid.DataSource = Dal.Db.VIEW_DETAILs;
}
On the Microsoft Sql Server, VIEW_DETAIL is defined as a view (which select query joins multiple ordinary tables). One of the source tables (let's say it's name is DETAIL) for the view query uses also a computed column that's present also in the view. Querying the view directly from Sql always returns consistent and updated results.
When in my program the source table DETAIL is updated, I call normally
grid.DataBind()
to update its content. Surprisingly nothing is updated (for instance the computed column mentioned above remains the old value). After dealing with some workarounds, I've found that changing the source above on the grid_NeedDataSource handler to
protected void grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
grid.DataSource = Dal.Db.VIEW_DETAILs.Where(x=> 1 == 1);
}
(e.g. adding a Where clause that is always true) the data now is correctly updated.
Any insights on this behavior?