Forgive me if this issue has been addressed before, I've been searching for a full day and can't make any progress.
Scenario:
I have a RadGrid using Advanced Data Binding (NeedDataSource event). Initial binding (load), paging, sorting are working fine, but filtering is not. I have a RadComboBox in a FilterTemplate of a GridBoundColumn. The RadComboBox is populated in the ItemDataBound event of the RadGrid. I do not use SqlDataSource, binding is done in the code-behind.
After the RadComboBox is populated (using the same data source (but only one column) that populates the RadGrid), I remove the duplicate items. This is the work around I found to avoid an additional data source issuing another connection to the database just to get a column distinct. Again, the items left in the RadComboBox are distinct.
Error:
When I select an item from the RadComboBox, I get the following error:
Selection out of range Parameter name: value
Code:
RadGrid:
Column:
Code Behind (bind RadComboBox):
I'm new to the controls, and I hope you can shed some light.
Thank you!
Scenario:
I have a RadGrid using Advanced Data Binding (NeedDataSource event). Initial binding (load), paging, sorting are working fine, but filtering is not. I have a RadComboBox in a FilterTemplate of a GridBoundColumn. The RadComboBox is populated in the ItemDataBound event of the RadGrid. I do not use SqlDataSource, binding is done in the code-behind.
After the RadComboBox is populated (using the same data source (but only one column) that populates the RadGrid), I remove the duplicate items. This is the work around I found to avoid an additional data source issuing another connection to the database just to get a column distinct. Again, the items left in the RadComboBox are distinct.
Error:
When I select an item from the RadComboBox, I get the following error:
Selection out of range Parameter name: value
Code:
RadGrid:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowFilteringByColumn
=
"True"
EnableViewState
=
"true"
CssClass
=
"GridViewSforms"
Skin
=
"Web20"
EnableEmbeddedSkins
=
"False"
Height
=
"510px"
Width
=
"941px"
ShowStatusBar
=
"True"
AlternatingItemStyle-BackColor
=
"#ededed"
ClientSettings-EnableRowHoverStyle
=
"true"
AllowPaging
=
"True"
AllowSorting
=
"True"
CellSpacing
=
"0"
GridLines
=
"None"
AutoGenerateColumns
=
"False"
ShowGroupPanel
=
"False"
EnableLinqExpressions
=
"False"
>
<
ClientSettings
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
AllowDragToGroup
=
"True"
EnableRowHoverStyle
=
"True"
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
/>
</
ClientSettings
>
<
AlternatingItemStyle
BackColor
=
"#EDEDED"
/>
<
MasterTableView
CommandItemDisplay
=
"Top"
>
Column:
<
telerik:GridBoundColumn
DataField
=
"CustomerProgramDescription"
Groupable
=
"true"
HeaderText
=
"Program"
UniqueName
=
"CustomerProgramDescription"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBoxCustomerProgramDescription"
runat
=
"server"
AppendDataBoundItems
=
"true"
DataTextField
=
"CustomerProgramDescription"
DataValueField
=
"CustomerProgramDescription"
OnClientSelectedIndexChanged
=
"CustomerProgramDescriptionIndexChanged"
OnDataBound
=
"RadComboBoxAllFilters_OnDataBound"
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("CustomerProgramDescription").CurrentFilterValue %>'
Width="100px">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlockProgram"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function CustomerProgramDescriptionIndexChanged(sender, args) {
var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
tableView.filter("CustomerProgramDescription", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
<
ItemStyle
Wrap
=
"False"
/>
<
HeaderStyle
Wrap
=
"false"
/>
</
telerik:GridBoundColumn
>
Code Behind (bind RadComboBox):
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
If TypeOf e.Item Is Telerik.Web.UI.GridFilteringItem Then
'Populate Filters by binding the combo to datasource
Dim filteringItem As Telerik.Web.UI.GridFilteringItem = CType(e.Item, Telerik.Web.UI.GridFilteringItem)
Dim myRadComboBox As Telerik.Web.UI.RadComboBox = DirectCast(filteringItem.FindControl("RadComboBoxCustomerProgramDescription"), Telerik.Web.UI.RadComboBox)
myRadComboBox.DataSource = myDataSet
myRadComboBox.DataTextField = "CustomerProgramDescription"
myRadComboBox.DataValueField = "CustomerProgramDescription"
myRadComboBox.ClearSelection()
myRadComboBox.DataBind()
End If
I'm new to the controls, and I hope you can shed some light.
Thank you!
22 Answers, 1 is accepted
0

Richard
Top achievements
Rank 1
answered on 09 May 2012, 10:54 PM
Mosart:
You would probably be better served to use the approach of creating a custom filtering column that's demonstrated in the Grid/Filtering Template Columns. All of the heavy lifting is already done for you here.
Hope this helps!
You would probably be better served to use the approach of creating a custom filtering column that's demonstrated in the Grid/Filtering Template Columns. All of the heavy lifting is already done for you here.
Hope this helps!
0

Mosart
Top achievements
Rank 1
answered on 10 May 2012, 03:33 AM
Thanks for your reply.
I noticed that this sample uses a SqlDataSource, which I don't. I've successfully accomplished the task with SqlDataSource before (just to try), but my challenge now is to do it with advanced databinding, (via NeedDataSource event). SqlDataSource (correct me if I'm wrong) is very database intensive in all postbacks/rebinds, and I'd much prefer to use local variable resources to bind (datasets).
Before I spend another full day trying, can you please inform if the sample you sent can be tweaked to use advanced data binding? I'm not getting anywhere with my assumptions.
Thanks for the help.
Mosart
I noticed that this sample uses a SqlDataSource, which I don't. I've successfully accomplished the task with SqlDataSource before (just to try), but my challenge now is to do it with advanced databinding, (via NeedDataSource event). SqlDataSource (correct me if I'm wrong) is very database intensive in all postbacks/rebinds, and I'd much prefer to use local variable resources to bind (datasets).
Before I spend another full day trying, can you please inform if the sample you sent can be tweaked to use advanced data binding? I'm not getting anywhere with my assumptions.
Thanks for the help.
Mosart
0
Hello Mosart,
Can you confirm that "
The error that you are getting is because item that you want to select in the combo is not longer there. Possibly because it is not bind yet, or it is bound to a datasource that does not contain the item that should be selected.
Regards,
Vasil
the Telerik team
Can you confirm that "
myDataSet
" is still containing the all items after filtering of the grid?The error that you are getting is because item that you want to select in the combo is not longer there. Possibly because it is not bind yet, or it is bound to a datasource that does not contain the item that should be selected.
Regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Richard
Top achievements
Rank 1
answered on 10 May 2012, 10:24 PM
Mosart,
In reviewing this further, you're correct to stay with implementing the filtering using the Filter Template for your case. It will actually be less work for you in the long run, since you're using the Advanced Data Binding method.
Now, with regards to your error...
Hope this is helpful!
In reviewing this further, you're correct to stay with implementing the filtering using the Filter Template for your case. It will actually be less work for you in the long run, since you're using the Advanced Data Binding method.
Now, with regards to your error...
You can try modifying your code for the combobox items code like this:
<Items>
<telerik:RadComboBoxItem Text="All" Value="" />
</Items>
Adding a Value ="" should help to avoid the error
Hope this is helpful!
0

Mosart
Top achievements
Rank 1
answered on 11 May 2012, 02:29 PM
Hello jumpstart,
I implemented your suggestion, and still got the same error:
Sys.WebForms.PageRequestManagerServerErrorException: Selection out of range
Parameter name: value
After ignoring the error break, I ended up with the RadComboBox selected with the item clicked for filtering, but the RadGrid still shows all items, as originally loaded. The only item that works (filters and returns no errors) is "All".
Thanks for your help.
Mosart
I implemented your suggestion, and still got the same error:
Sys.WebForms.PageRequestManagerServerErrorException: Selection out of range
Parameter name: value
After ignoring the error break, I ended up with the RadComboBox selected with the item clicked for filtering, but the RadGrid still shows all items, as originally loaded. The only item that works (filters and returns no errors) is "All".
Thanks for your help.
Mosart
0
Hi Mosart,
You can turn off the Ajax temporarily in your page in order to see the actual CallStack from the server exception that you get. This could help in determination when exactly the problem happens..
Regards,
Vasil
the Telerik team
You can turn off the Ajax temporarily in your page in order to see the actual CallStack from the server exception that you get. This could help in determination when exactly the problem happens..
Regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Mosart
Top achievements
Rank 1
answered on 15 May 2012, 01:26 PM
More info: I noticed that the event RadGrid1_ItemDataBound is not fired for ItemType FilteringItem when selecting a filter item from the RadComboBox, except when selecting "All". I populate the filtering RadComboBox on "TypeOf e.Item Is Telerik.Web.UI.GridFilteringItem".
Thank you for your reply. Please let me know if you need additional info. Looking forward to get this solved.
Mosart
(sorry, I can't get rid of the large font)
Server Error in '/' Application.
Selection out of range
Parameter name: value
Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code. Exception Details: System.ArgumentOutOfRangeException: Selection out of range
Parameter name: value
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
|
Stack Trace:
|
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
0
Hello Mosart,
Well it really looks that the Item that is selected does not exist after rebind of the ComboBox. So please confirm that all records are included in the DataSource of the Combobox even if the grid filters.
Kind regards,
Vasil
the Telerik team
Well it really looks that the Item that is selected does not exist after rebind of the ComboBox. So please confirm that all records are included in the DataSource of the Combobox even if the grid filters.
Kind regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Mosart
Top achievements
Rank 1
answered on 18 May 2012, 04:25 PM
Vasil,
The DataSource used by the RadComboBox is the same used by the RadGrid (fed via NeedDataSource event). I have it now as a Session variable (dataset), so I know the datasource exists and is valid (it fills the grid and the combo on initial load). I think the problem is during the rebind of the grid, where it does not rebind the Filter items.
What I noticed (and I know I'm repeating myself) is that after seleting an item from the filter RadComboBox, the event ItemDataBound of the grid is not fired for the filter item type (TypeOf e.Item Is Telerik.Web.UI.GridFilteringItem). The event fires several times (to rebind dataItems, etc...) but none to type GridFilteringItem.
I have a better understanding of the problem with your answers, but still have no solution. Let me know what you can suggest within my scenario. Thank you.
With regards,
Mosart
The DataSource used by the RadComboBox is the same used by the RadGrid (fed via NeedDataSource event). I have it now as a Session variable (dataset), so I know the datasource exists and is valid (it fills the grid and the combo on initial load). I think the problem is during the rebind of the grid, where it does not rebind the Filter items.
What I noticed (and I know I'm repeating myself) is that after seleting an item from the filter RadComboBox, the event ItemDataBound of the grid is not fired for the filter item type (TypeOf e.Item Is Telerik.Web.UI.GridFilteringItem). The event fires several times (to rebind dataItems, etc...) but none to type GridFilteringItem.
I have a better understanding of the problem with your answers, but still have no solution. Let me know what you can suggest within my scenario. Thank you.
With regards,
Mosart
0
Accepted
Hello Mosart,
Try to handle the grid's ItemCreated event, which should be always fired for the filter items, and bind your combo box in there.
Kind regards,
Vasil
the Telerik team
Try to handle the grid's ItemCreated event, which should be always fired for the filter items, and bind your combo box in there.
Kind regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Mosart
Top achievements
Rank 1
answered on 20 May 2012, 04:08 PM
THAT did the trick. Working perfectly.
I have two more issues in the same grid, please suggest if I should open new threads (I can't find answers for them):
1. Manually handled export to Excel via ItemCommand (RadGrid1.MasterTableView.ExportToExcel()) returns an error, because I have a column with a RadComboBox (in every row). During ItemCommand, the RadComboBox of the DataItem (row) can't be found (FindControl returns null). I'm not sure how the excel should be exported in this scenario. Ideally, the combo's selected text should be written to excel.
2. A textbox column filter does not respect the FilterDelay="3". Immediately after typing, the postback occurs (and obviously, discontinue typing as the refresh loses control focus).
Thank you for the help.
Mosart
I have two more issues in the same grid, please suggest if I should open new threads (I can't find answers for them):
1. Manually handled export to Excel via ItemCommand (RadGrid1.MasterTableView.ExportToExcel()) returns an error, because I have a column with a RadComboBox (in every row). During ItemCommand, the RadComboBox of the DataItem (row) can't be found (FindControl returns null). I'm not sure how the excel should be exported in this scenario. Ideally, the combo's selected text should be written to excel.
2. A textbox column filter does not respect the FilterDelay="3". Immediately after typing, the postback occurs (and obviously, discontinue typing as the refresh loses control focus).
Thank you for the help.
Mosart
0
Accepted
Hi Mosart,
1. Set try with "ExportOnlyData = True" in the ExportSettings of RadGrid. Another solution will be to handle the grid's ItemDataBound event and hide the combo box and show your custom label with all values from the combo.
2. The FilterDelay property expects value is in milliseconds. So if you use "3" the filtering will happen immediately after typing. Try to set FilterDelay="3000", and see if it will work correctly.
All the best,
Vasil
the Telerik team
1. Set try with "ExportOnlyData = True" in the ExportSettings of RadGrid. Another solution will be to handle the grid's ItemDataBound event and hide the combo box and show your custom label with all values from the combo.
2. The FilterDelay property expects value is in milliseconds. So if you use "3" the filtering will happen immediately after typing. Try to set FilterDelay="3000", and see if it will work correctly.
All the best,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Mukul
Top achievements
Rank 1
answered on 15 Dec 2012, 03:11 PM
Hi Vasil,
I have RadComboBox1 and RadRomboBox2 in the filter template. I did the binding of the RadComboBoxes again in the ItemCreated event and it works perfectly fine. But my problem is that how can i populate RadComboBox1 based on the value selected in RadComboBox2. I am having data in a SharePoint list and both the RadComboBoxes are databound. To elaborate it further, if suppose i have 10 items each in Radcombobox 1 and RadComboBox2. I select a filter in RadComboBox2, i get one record which is fine. But there are 3 related data out of 10 in RadComboBox1. How can i show only 3 data in RadComboBox1. Its showing all 10 in RadComboBox1. Please Help.
Regards,
Mukul
I have RadComboBox1 and RadRomboBox2 in the filter template. I did the binding of the RadComboBoxes again in the ItemCreated event and it works perfectly fine. But my problem is that how can i populate RadComboBox1 based on the value selected in RadComboBox2. I am having data in a SharePoint list and both the RadComboBoxes are databound. To elaborate it further, if suppose i have 10 items each in Radcombobox 1 and RadComboBox2. I select a filter in RadComboBox2, i get one record which is fine. But there are 3 related data out of 10 in RadComboBox1. How can i show only 3 data in RadComboBox1. Its showing all 10 in RadComboBox1. Please Help.
Regards,
Mukul
0
Hello Mukul,
See this online demo that shows how to bind RadComboBox that depends on the selected value of another one:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx
Regards,
Vasil
the Telerik team
See this online demo that shows how to bind RadComboBox that depends on the selected value of another one:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx
Regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Sergey
Top achievements
Rank 1
answered on 30 Mar 2015, 10:10 AM
I'm expiriencing similar problem
I have Grid and 2 filters. Second filter is being filled based on selected value in first one.
Here is the code
All is working fine untill you change First filter selected value (in case value in second filter was changed). It throws "Selection out of range Parameter name: value".
I even tried to add items to the second combobox manually (instead of binding it). In this case on code behind it doesn't throw exception but it does throw it on client side (javascript). Error is the same.
I've tried almost everything but still cannot make it work.
I have Grid and 2 filters. Second filter is being filled based on selected value in first one.
Here is the code
protected
void
OnItemCreated(
object
sender, GridItemEventArgs e)
{
GridFilteringItem item = e.Item
as
GridFilteringItem;
if
(item !=
null
)
{
RadComboBox planIdCombo = (RadComboBox)item.FindControl(
"planIdFilterComboBox"
);
RadComboBox pbpIdCombo = (RadComboBox)item.FindControl(
"pbpIdFilterComboBox"
);
planIdCombo.DataSource = SNPConfigView.Select(t => t.PlanID).Distinct().OrderBy(t => t);
planIdCombo.DataBind();
planIdCombo.SelectedValue = e.Item.OwnerTableView.GetColumn(
"PlanId"
).CurrentFilterValue;
pbpIdCombo.DataSource = SNPConfigView.Where(t => t.PlanID == planIdCombo.SelectedValue ||
string
.IsNullOrEmpty(planIdCombo.SelectedValue)).Select(t => t.PBPID).Distinct().OrderBy(t => t);
pbpIdCombo.DataBind();
pbpIdCombo.SelectedValue = e.Item.OwnerTableView.GetColumn(
"PbpId"
).CurrentFilterValue;
}
}
All is working fine untill you change First filter selected value (in case value in second filter was changed). It throws "Selection out of range Parameter name: value".
I even tried to add items to the second combobox manually (instead of binding it). In this case on code behind it doesn't throw exception but it does throw it on client side (javascript). Error is the same.
I've tried almost everything but still cannot make it work.
<
telerik:GridBoundColumn
DataField
=
"PlanId"
HeaderText
=
"Plan ID"
UniqueName
=
"PlanId"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"EqualTo"
ShowFilterIcon
=
"false"
FilterControlWidth
=
"70px"
>
<
ItemStyle
CssClass
=
"center"
></
ItemStyle
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"planIdFilterComboBox"
Width
=
"60"
AppendDataBoundItems
=
"True"
OnItemDataBound
=
"OnPlanIdFilterComboItemDataBound"
SelectedValue='<%# Container.OwnerTableView.GetColumn("PlanId").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="PlanIdFilterComboIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
Value
=
""
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"planIdFilteringScripBlock"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function PlanIdFilterComboIndexChanged(sender, args) {
var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
tableView.filter("PlanId", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PBPID"
HeaderText
=
"PBP"
UniqueName
=
"PBPID"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"Contains"
ShowFilterIcon
=
"false"
FilterControlWidth
=
"40px"
>
<
HeaderStyle
Width
=
"70px"
></
HeaderStyle
>
<
ItemStyle
CssClass
=
"center"
></
ItemStyle
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"pbpIdFilterComboBox"
Width
=
"60"
EnableViewState
=
"False"
OnItemDataBound
=
"OnPbpIdFilterComboItemDataBound"
SelectedValue='<%# Container.OwnerTableView.GetColumn("PBPID").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="PbpIdFilterComboIndexChanged">
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"pbpIdFilteringScripBlock"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function PbpIdFilterComboIndexChanged(sender, args) {
var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
tableView.filter("PBPID", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
0
Hello Sergey,
The code looks correct so it is hard to tell what could be the issue here.
Could you send us CallStack of the JavaScript exception that you get? Or some complete markup that we can test here.
If possible set AllowCustomText for ComboBox to see if the exception will still happen. In this case you will see if there is some incorrect logic and your value stays old after you rebind given ComboBox.
Regards,
Vasil
Telerik
The code looks correct so it is hard to tell what could be the issue here.
Could you send us CallStack of the JavaScript exception that you get? Or some complete markup that we can test here.
If possible set AllowCustomText for ComboBox to see if the exception will still happen. In this case you will see if there is some incorrect logic and your value stays old after you rebind given ComboBox.
Regards,
Vasil
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0

Sergey
Top achievements
Rank 1
answered on 31 Mar 2015, 03:24 PM
Hello, Vasil,
Here is stack trace:
Here is grid markup:
I've tried to set AllowCustomText for comboboxes but it still throws exception on binding.
Please see screenshot in the attachments.
Here is stack trace:
at Telerik.Web.UI.RadComboBox.PerformDataBinding(IEnumerable dataSource)
at Telerik.Web.UI.RadComboBox.OnDataSourceViewSelectCallback(IEnumerable data)
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
at Telerik.Web.UI.RadComboBox.OnDataBinding(EventArgs e)
at Telerik.Web.UI.RadComboBox.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at Telerik.Web.UI.RadComboBox.DataBind()
at PDMWeb.EENRL.Views.Admin.SNPConfiguration.SNPConfiguration.OnItemCreated(Object sender, GridItemEventArgs e) in d:\PROJECTS\TMS\Main\5.2.2\Common\Solutions\Projects\PDMWeb\EENRL\Views\admin\SNPConfiguration\SNPConfiguration.ascx.cs:line 286
at Telerik.Web.UI.RadGrid.OnItemCreated(GridItemEventArgs e)
at Telerik.Web.UI.RadGrid.CallOnItemCreated(GridItemEventArgs e)
Here is grid markup:
<
telerik:RadGrid
runat
=
"server"
ID
=
"snpGrid"
Skin
=
"Default"
AutoGenerateColumns
=
"False"
Width
=
"600px"
AllowFilteringByColumn
=
"True"
OnNeedDataSource
=
"OnNeedDataSource"
OnItemCreated
=
"OnItemCreated"
>
<
GroupingSettings
CaseSensitive
=
"false"
></
GroupingSettings
>
<
MasterTableView
NoMasterRecordsText
=
"No records found"
DataKeyNames
=
"ID"
EnableHierarchyExpandAll
=
"true"
Style
=
"width: auto"
CssClass
=
"panel-body"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"PlanId"
HeaderText
=
"Plan ID"
UniqueName
=
"PlanId"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"EqualTo"
ShowFilterIcon
=
"false"
FilterControlWidth
=
"70px"
>
<
ItemStyle
CssClass
=
"center"
></
ItemStyle
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"planIdFilterComboBox"
AllowCustomText
=
"True"
Width
=
"60"
AppendDataBoundItems
=
"True"
OnItemDataBound
=
"OnPlanIdFilterComboItemDataBound"
SelectedValue='<%# Container.OwnerTableView.GetColumn("PlanId").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="PlanIdAuditFilterComboIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
Value
=
""
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"planIdFilteringScripBlock"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function PlanIdAuditFilterComboIndexChanged(sender, args) {
var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
tableView.filter("PlanId", args.get_item().get_value(), "EqualTo");
var pbpIdFilter = window.SNP.pbpidFilter;
pbpIdFilter.set_value('');
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PBPID"
HeaderText
=
"PBP"
UniqueName
=
"PBPID"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"Contains"
ShowFilterIcon
=
"false"
FilterControlWidth
=
"40px"
>
<
HeaderStyle
Width
=
"70px"
></
HeaderStyle
>
<
ItemStyle
CssClass
=
"center"
></
ItemStyle
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"pbpIdFilterComboBox"
Width
=
"60"
AllowCustomText
=
"True"
AppendDataBoundItems
=
"True"
OnItemDataBound
=
"OnPbpIdFilterComboItemDataBound"
SelectedValue='<%# Container.OwnerTableView.GetColumn("PBPID").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="PbpIdAuditFilterComboIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
Value
=
""
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"pbpIdFilteringScripBlock"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function PbpIdAuditFilterComboIndexChanged(sender, args) {
var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
tableView.filter("PBPID", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"SnpType"
HeaderText
=
"SNP Type"
UniqueName
=
"SnpType"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"Contains"
ShowFilterIcon
=
"false"
FilterControlWidth
=
"110px"
>
<
ItemStyle
CssClass
=
"center"
></
ItemStyle
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"snpTypeFilterComboBox"
Width
=
"105px"
SelectedValue='<%# Container.OwnerTableView.GetColumn("SnpType").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="SNPTypeFilterComboIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
Value
=
""
/>
<
telerik:RadComboBoxItem
Text
=
"Chronic"
Value
=
"Chronic"
/>
<
telerik:RadComboBoxItem
Text
=
"Dual"
Value
=
"Dual"
/>
<
telerik:RadComboBoxItem
Text
=
"Institutional"
Value
=
"Institutional"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"snpTypeFilteringScripBlock"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function SNPTypeFilterComboIndexChanged(sender, args) {
var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
tableView.filter("SnpType", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"ESRD"
HeaderText
=
"ESRD"
UniqueName
=
"ESRD"
ReadOnly
=
"True"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"EqualTo"
ShowFilterIcon
=
"false"
FilterControlWidth
=
"40px"
>
<
HeaderStyle
Width
=
"60px"
></
HeaderStyle
>
<
ItemStyle
CssClass
=
"center"
></
ItemStyle
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"esrdFilterComboBox"
Width
=
"50px"
SelectedValue='<%# Container.OwnerTableView.GetColumn("ESRD").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="EsrdFilterComboIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
Value
=
""
/>
<
telerik:RadComboBoxItem
Text
=
"Yes"
Value
=
"True"
/>
<
telerik:RadComboBoxItem
Text
=
"No"
Value
=
"False"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"esrdFilteringScripBlock"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function EsrdFilterComboIndexChanged(sender, args) {
var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
tableView.filter("ESRD", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridCheckBoxColumn
>
<
telerik:GridBoundColumn
DataField
=
"MonthOfEligibility"
HeaderText
=
"Months Of Eligibility"
UniqueName
=
"MonthOfEligibility"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"EqualTo"
ShowFilterIcon
=
"false"
FilterControlWidth
=
"30px"
>
<
ItemStyle
CssClass
=
"center"
></
ItemStyle
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"mothsOfEligFilterComboBox"
Width
=
"40px"
SelectedValue='<%# Container.OwnerTableView.GetColumn("MonthOfEligibility").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="MonthsOfEligFilterComboIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
Value
=
""
/>
<
telerik:RadComboBoxItem
Text
=
"1"
Value
=
"1"
/>
<
telerik:RadComboBoxItem
Text
=
"2"
Value
=
"2"
/>
<
telerik:RadComboBoxItem
Text
=
"3"
Value
=
"3"
/>
<
telerik:RadComboBoxItem
Text
=
"4"
Value
=
"4"
/>
<
telerik:RadComboBoxItem
Text
=
"5"
Value
=
"5"
/>
<
telerik:RadComboBoxItem
Text
=
"6"
Value
=
"6"
/>
<
telerik:RadComboBoxItem
Text
=
"7"
Value
=
"7"
/>
<
telerik:RadComboBoxItem
Text
=
"8"
Value
=
"8"
/>
<
telerik:RadComboBoxItem
Text
=
"9"
Value
=
"9"
/>
<
telerik:RadComboBoxItem
Text
=
"10"
Value
=
"10"
/>
<
telerik:RadComboBoxItem
Text
=
"11"
Value
=
"11"
/>
<
telerik:RadComboBoxItem
Text
=
"12"
Value
=
"12"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"monthOfEligFilteringScripBlock"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function MonthsOfEligFilterComboIndexChanged(sender, args) {
var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
tableView.filter("MonthOfEligibility", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
HeaderStyle
CssClass
=
"center"
></
HeaderStyle
>
<
NestedViewTemplate
>
<
div
style
=
"background-color: #EEEEEE; height: 100%;"
>
<
div
class
=
"nestedView"
>
<
div
class
=
"snp-title"
>
Additional information:
</
div
>
<
asp:Panel
runat
=
"server"
Visible="<%# ((SNPConfiguration)Container.DataItem).SNPType == SNPConfigurationPresenter.Constatns.SNPType.Chronic.ToString() %>">
<
table
>
<
tr
>
<
td
style
=
"vertical-align: top; width: 110px;"
>
<
b
>Chronic Types: </
b
>
</
td
>
<
td
>
<%# ((SNPConfiguration)Container.DataItem).ConfigurationDetails%>
</
td
>
</
tr
>
</
table
>
</
asp:Panel
>
<
asp:Panel
runat
=
"server"
Visible="<%# ((SNPConfiguration)Container.DataItem).SNPType == SNPConfigurationPresenter.Constatns.SNPType.Dual.ToString() %>">
<
table
>
<
tr
>
<
td
style
=
"vertical-align: top; width: 50px;"
>
<
b
>State:</
b
>
</
td
>
<
td
>
<%# ((SNPConfiguration)Container.DataItem).ConfigurationDetails%>
</
td
>
</
tr
>
</
table
>
</
asp:Panel
>
<
asp:Panel
runat
=
"server"
Visible="<%# ((SNPConfiguration)Container.DataItem).SNPType == SNPConfigurationPresenter.Constatns.SNPType.Institutional.ToString() %>">
No Additional information
</
asp:Panel
>
</
div
>
</
div
>
</
NestedViewTemplate
>
</
MasterTableView
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
ScrollHeight
=
"400px"
></
Scrolling
>
<
ClientEvents
OnGridCreated
=
"GridCreated"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
I've tried to set AllowCustomText for comboboxes but it still throws exception on binding.
Please see screenshot in the attachments.
0
Hello Sergey,
This error happens because when you change the DataSource the old SelectedValue does not appear in the new DataSource.
You can fix the problem by setting SelectedValue="", before changing the datasource.
Regards,
Vasil
Telerik
This error happens because when you change the DataSource the old SelectedValue does not appear in the new DataSource.
You can fix the problem by setting SelectedValue="", before changing the datasource.
Regards,
Vasil
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0

Sergey
Top achievements
Rank 1
answered on 03 Apr 2015, 02:35 PM
I tried to do that once i got the error :). It doesn't work. I throws the same exception. Seems the problem is that somewhere during databinding it uses some cached SelectedValue.
0

Sergey
Top achievements
Rank 1
answered on 03 Apr 2015, 03:38 PM
Here is the sample - Link
0
Hi Sergey,
Indeed there is variable called cachedSelectedValue. It is set when the ClientState is load, and then it is used to select the value when the ComboBox binds.
This is meant to be done when the ViewState is loaded.
The grid fires ItemCreated event for items when it create them before Page_Load for loading their viewstate correctly. And then after Page_Load to create the structure for the new request.
If you like to change the DataSouce of the ComboBox you should change it after the Page_Load. When the grid create its new structure.
You can raise a flag in Page_Load, and then when you handle the OnItemCreated to make sure this flag is true, and only then to rebind the combo.
Regards,
Vasil
Telerik
Indeed there is variable called cachedSelectedValue. It is set when the ClientState is load, and then it is used to select the value when the ComboBox binds.
This is meant to be done when the ViewState is loaded.
The grid fires ItemCreated event for items when it create them before Page_Load for loading their viewstate correctly. And then after Page_Load to create the structure for the new request.
If you like to change the DataSouce of the ComboBox you should change it after the Page_Load. When the grid create its new structure.
You can raise a flag in Page_Load, and then when you handle the OnItemCreated to make sure this flag is true, and only then to rebind the combo.
Regards,
Vasil
Telerik
See What's Next in App Development. Register for TelerikNEXT.