When y try to filter, the exception "Invalid column name" shows up
Here is the aspx
Following the example from here
I suspect the problem may be because the SQLDataSource is composed by joins instead of being a single table
any idea on how to solve this?
Here is the aspx
<
p
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid2"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid2"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
/>
<
telerik:RadGrid
ID
=
"RadGrid1"
Width
=
"100%"
DataSourceID
=
"SqlDataSource1"
AllowFilteringByColumn
=
"True"
AllowSorting
=
"True"
AllowPaging
=
"True"
PageSize
=
"7"
runat
=
"server"
AutoGenerateColumns
=
"False"
OnPreRender
=
"RadGrid1_PreRender"
ShowStatusBar
=
"true"
EnableLinqExpressions
=
"false"
>
<
MasterTableView
DataKeyNames
=
"IdEmpresa"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"Empresa"
DataField
=
"Empresa"
HeaderText
=
"Empresa"
AllowFiltering
=
"false"
HeaderStyle-Width
=
"200px"
/>
<
telerik:GridBoundColumn
UniqueName
=
"Supergrupo"
DataField
=
"Supergrupo"
HeaderText
=
"Super Grupo"
HeaderStyle-Width
=
"200px"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBoxTitle"
DataSourceID
=
"SqlDataSource2"
DataTextField
=
"SuperGrupo"
AutoPostBack
=
"false"
DataValueField
=
"SuperGrupo"
Height
=
"200px"
AppendDataBoundItems
=
"true"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("SuperGrupo").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="TitleIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"Todos"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function TitleIndexChanged(sender, args)
{
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("SuperGrupo", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"Grupo"
DataField
=
"Grupo"
HeaderText
=
"Grupo"
HeaderStyle-Width
=
"200px"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBoxCity"
DataSourceID
=
"SqlDataSource3"
DataTextField
=
"Grupo"
AutoPostBack
=
"false"
DataValueField
=
"Grupo"
Height
=
"100px"
AppendDataBoundItems
=
"true"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Grupo").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="CityIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock2"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function CityIndexChanged(sender, args)
{
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("Grupo", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
br
/>
<
telerik:RadToolTip
ID
=
"RadToolTip1"
runat
=
"server"
OffsetY
=
"3"
Position
=
"TopCenter"
ShowCallout
=
"false"
Height
=
"20px"
ShowEvent
=
"fromcode"
/>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
ConnectionString="<%$ ConnectionStrings:BTIMEXICO_DESConnectionC %>"
ProviderName="System.Data.SqlClient" runat="server"
SelectCommand="SELECT E.idEmpresa, E.Nombre AS Empresa, GE.idgrupo, G.Descripcion AS Grupo, SG.Descripcion AS SuperGrupo
FROM tbl_empresa E
LEFT JOIN tbl_grupoempresa GE
ON E.idEmpresa = GE.idEmpresa
LEFT JOIN tbl_grupos G
ON GE.idgrupo = G.idgrupo
LEFT JOIN tbl_Supergrupo SG
ON SG.idsupergrupo = G.idsupergrupo
ORDER BY Nombre">
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource2"
ConnectionString="<%$ ConnectionStrings:BTIMEXICO_DESConnectionC %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT DISTINCT Descripcion AS SuperGrupo FROM tbl_supergrupo"
runat="server">
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource3"
ConnectionString="<%$ ConnectionStrings:BTIMEXICO_DESConnectionC %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT DISTINCT Descripcion AS Grupo FROM tbl_grupos"
runat="server">
</
asp:SqlDataSource
>
</
p
>
And the Code-behind
using
System;
using
System.Linq;
using
System.Data;
using
Telerik.Web.UI;
namespace
BCD.PP.VIEW
{
public
partial
class
Client_Question_Config_A : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
}
}
protected
void
ImportedFilter_ItemDataBound(
object
sender, RadComboBoxItemEventArgs e)
{
DataRowView rowView = (DataRowView)e.Item.DataItem;
if
(rowView[
"Bool"
]
is
DBNull)
{
e.Item.Text =
"No"
;
e.Item.Value =
"0"
;
}
else
if
((
bool
)rowView[
"Bool"
])
{
e.Item.Text =
"Yes"
;
e.Item.Value =
"1"
;
}
}
protected
void
RadGrid1_PreRender(
object
sender, System.EventArgs e)
{
if
(RadGrid1.MasterTableView.FilterExpression !=
string
.Empty)
{
RefreshCombos();
}
}
protected
void
RefreshCombos()
{
SqlDataSource2.SelectCommand = SqlDataSource2.SelectCommand +
" WHERE "
+ RadGrid1.MasterTableView.FilterExpression.ToString();
SqlDataSource3.SelectCommand = SqlDataSource3.SelectCommand +
" WHERE "
+ RadGrid1.MasterTableView.FilterExpression.ToString();
RadGrid1.MasterTableView.Rebind();
//<<< Here is where the exception pops up
}
}
}
Following the example from here
I suspect the problem may be because the SQLDataSource is composed by joins instead of being a single table
any idea on how to solve this?