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

RadGrid Databinding Error

2 Answers 128 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ban
Top achievements
Rank 1
Ban asked on 05 Jan 2009, 12:21 PM
I am using RadGrid with Edit Form type 'Template' it contains two RadComboBox the second one depend on the selection of the first one and both of them use Binding Selected Value, but I have this error when I run my project " Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control", I do not know what is the wrong thing I made in my project. Any suggestion on this case !!!
Thanks
Ban

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Jan 2009, 01:23 PM
Hello Ban,

Try binding the SelectedValue of the RadComboBox as shown below and see if it helps:
aspx:
<telerik:GridTemplateColumn UniqueName="Place" HeaderText="PlaceTo"
        <ItemTemplate>            
        <telerik:RadComboBox ID="RadComboBox3" AutoPostBack="true" runat="server" SelectedValue='<%# DataBinder.Eval(Container.DataItem,"Place") %>' DataSourceID="SqlDataSource1" DataTextField="Place" DataValueField="Place" AppendDataBoundItems="True">          
            </telerik:RadComboBox> 
        </ItemTemplate>         
 </telerik:GridTemplateColumn> 

Thanks
Princy.
0
Ban
Top achievements
Rank 1
answered on 06 Jan 2009, 11:16 AM

Hi Princy

Thanks for your replay, I follow the way you told me and its work, but because it is (Eval) not (Bind) that mean no data will be in the comboBox  to save directly to my table and I tried to handle  this manually  by saveing  the data of the ComboBox to my table but I faced  some problems so I decide  to chang the way from Template  to UserControl so I can control my data and Controls in my page and I back to my old way (The Bind) and I face he same old problem so I switched  to the way you gave me hope  every thing go on right but I surprised with  another error "System.Web.UI.Control dose not contain a definition for 'DataItem' " so Please help me and advice me how can I solve this new error ..
Thanks

Ban
 

Tags
Grid
Asked by
Ban
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ban
Top achievements
Rank 1
Share this question
or