Error message "Cannot find any bindable properties"
This error usually occurs when the DataSource for the grid is null/not assigned or if you do not handled properly the NeedDataSource event. If you implement hierarchical grid structure you may receive this server error if the DataSources for the detail tables in the grid body are nulls or there are problems with the handling of the DetailTableDataBind event (used for detail table binding).
Note that if you want to set empty sources for the MasterTableView/DetailTables in the grid in some occasions you can use the following syntax:
| C# |
Copy Code |
|
<GridInstance>.DataSource = new Object[0]; |
| VB.NET |
Copy Code |
|
<GridInstance>.DataSource = new Object(){} |
or
| C# |
Copy Code |
|
<DetailTableInstance>.DataSource = new Object[0]; |
| VB.NET |
Copy Code |
|
<DetailTableInstance>.DataSource = new Object(){} |
Error message
"Unexpected ajax response was received from the server. This may be caused by one of the following reasons:
- Server.Transfer
- Incorrect loading of an "Ajaxified" user control
- Custom http handler."
The message is quite descriptive. Below are several resources in regards with this matter:
Dynamic loading of user controls
Dynamic loading of user controls with ajax controls
Error message "Telerik.WebControls.GridInsertionObject does not contain a property with the name <some_name>"
Or
'DropDownList' has a SelectedValue which is invalid because it does not exist in the list of items
The reason for this error is that your grid instance can not bind a value for the newly inserted item through the Eval()/Bind() syntax you hard-coded (as you may have seen from the stack trace of the error).
This problem can be fixed in the following ways:
-
preset the default value of the control(s) when binding to a grid item on the RadGrid.InitInsertCommandName command.
For auto-generated edit forms, you should prepare a Hashtable (or other dictionary) with the predefined values for your insert form controls and pass it as parameter to the InsertItem method:
| C# |
Copy Code |
|
protected void RadGrid1_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) { //Add new" button clicked e.Canceled = true; 'Prepare an IDictionary with the predefined values System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary(); newValues[ "<ColumnDataField>"] = "<predefined_value>"; 'Insert the item and rebind e.Item.OwnerTableView.InsertItem(newValues); } } |
| VB.NET |
Copy Code |
|
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles RadGrid1.ItemCommand If e.CommandName = RadGrid.InitInsertCommandName Then e.Canceled = True Dim newValues As System.Collections.Specialized.ListDictionary = New System.Collections.Specialized.ListDictionary() newValues( "<ColumnDataField>") = "<predefined_value>" e.Item.OwnerTableView.InsertItem(newValues) End If End Sub |
More info about how to set predefined values for different auto-generated column editors you can find
at the end of
this topic.
 |
When you have template column in the grid make sure that you specify the field to which you bind the control inside the template column as key for the dictionary object (passed to the InsertItem(newValues) method). For example:
<rad:GridTemplateColumn HeaderText="Country" UniqueName="CountryColumn"> <EditItemTemplate> <asp:DropDownList id="ddList1" Height="200px" runat="server" DataTextField="Country" DataValueField="Country" DataSource='<%# LoadCountryNames() %>' SelectedValue='<%# Bind("Country")%>' /> </EditItemTemplate> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem,"Country") %> </ItemTemplate> </rad:GridTemplateColumn>
<rad:GridTemplateColumn HeaderText="Check/Uncheck" UniqueName="BoolColumn"> <EditItemTemplate> <asp:CheckBox ID="chkBoxEdit" runat="server" Checked='<%# Bind("Bool") %>' /> </EditItemTemplate> <ItemTemplate> <asp:CheckBox ID="chkBoxDefault" runat="server" Checked='<%# Eval("Bool") %>' /> </ItemTemplate> </rad:GridTemplateColumn>
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles RadGrid1.ItemCommand If (e.CommandName = RadGrid.InitInsertCommandName) Then e.Canceled = True 'Prepare an IDictionary with the predefined values Dim newValues As System.Collections.Specialized.ListDictionary = New System.Collections.Specialized.ListDictionary()
'set initial selection for the dropdown list on init insert newValues("Country") = "Germany"
'set initial checked state for the checkbox on init insert newValues("Bool") = False
'Insert the item and rebind e.Item.OwnerTableView.InsertItem(newValues) End If End Sub
The same principle is applicable when you have wrapped dropdown list/checkbox in FormTemplate custom edit form (see this online demo for more info).
The other option is to set AppendDataBoundItems="true" for the dropdown list (residing in edit template of template column or form template custom edit form) and add default empty item in the dropdown control:
<rad:GridTemplateColumn> <ItemTemplate> <%# Eval("ProductID") %> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="DropDownList1" AppendDataBoundItems="true" DataSourceID="AccessDataSource2" DataTextField="ProductID" DataValueField="ProductID" SelectedValue='<%# Bind("ProductID") %>' runat="server"> <asp:ListItem Text="" Value="" /> </asp:DropDownList> </EditItemTemplate> </rad:GridTemplateColumn>
<EditFormSettings EditFormType="Template"> <FormTemplate> ---------- <asp:DropDownList ID="DropDownList1" AppendDataBoundItems="true" DataSourceID="AccessDataSource2" DataTextField="ProductID" DataValueField="ProductID" SelectedValue='<%# Bind("ProductID") %>' runat="server"> <asp:ListItem Text="" Value="" /> </asp:DropDownList> ----------- </FormTemplate> </EditFormSettings>
This is a codeless approach, however have in mind that this empty option will be displayed in the dropdown editor of an existing edited grid row as well. |
For custom edit forms (WebUserControl/FormTemplate) you can refer to the last paragraph in this help topic.
do not set declaratively (using Eval()/Bind() expression) the value for your control(s) in the html code of the page/user control
Error message "These columns don't currently have unique values"
There are two possible reasons for this error message to appear:
- There are items in your database with values which differ by spaces. For example:
|
Copy Code |
|
//arbitrary column string values billy dean heath j aldrich[SPACE] heath j aldrich heath j aldrich HEATH ALDRICH HEATH ALDRICH |
When you strip the space from the item/or add space at the end of the string for the other two fields with the same name, the problem should disappear.
It seems that the relation created by the DataSource control and the grid on grouping are not unique when the difference between these field values is merely a space.
Currently we are researching this matter thoroughly and will do everything possible to fix it in one of the next versions of the grid.
- Another possible reason for this problem (which appears intermittently) could be that you have cells in a grid column with the same text but with different captions. We suggest you to set the RadGridInstance.GroupSettings.CaseSensitive option of the grid to false.
- You use FieldAliases for the grouping expressions. Removing the FieldAlias from the respective group expression(s) should prevent the exception generation.
Please note, however, that with such a modification, the relations when you group by the respective column may return different results when you drag items with equal text and different captions. Actually the source of the issue is related to the Microsoft Data Components (DataTable, DataSet, etc.) and we will try to find an accurate solution for one of the upcoming versions of Telerik RadGrid.
Error message "The data source '<dataSourceName>' does not support sorting with IEnumerable data. Automatic sorting is only supported with DataView, DataTable, and DataSet"
Sorting of generic lists returned from SelectMethod of ObjectDataSource control cannot be handled by any web grid (including the MS GridView). You should implement the sorting at object data source level. This online resource elaborates on the subject:
http://www.vinull.com/Post/2007/04/17/aspnet-sorting-a-gridview-with-custom-o.aspx#comments
Other possible solution is to bind this collection inside the NeedDataSource handler - in this case RadGrid will able to sort the data without any problems.
The third option is to set the OverrideDataSourceControlSorting property of the MasterTableView/GridTableView to true (the default value is false). With this setting you will force the grid to override DataSourceControl's default sorting and use the RadGrid native sorting instead. Hence the solution is applicable in case of ObjectDataSource with IEnumerable data (or other custom data source controls) without implemented sorting as depicted in point 1.