Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."http://forums.asp.net/t/1048637.aspx/1?Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Fri, 23 Oct 2009 20:27:40 -040010486371476392http://forums.asp.net/p/1048637/1476392.aspx/1?Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>I am trying to dynamically bind to a repeater. The code below shows both my codebehind and my ASPX page. </p> <p>To give you some background as to why I am doing it this way is because when I try to statically place the Datasource on the page. I cannot pass the variable that I need to the datasource</p> <p>The query being this <font color="#800000" size="2">&quot;SELECT resume_file_size, resume_file_type, resume_name, date_uploaded, resume_file_name, viewedcount FROM resumes WHERE (uid = @uid)&quot;</font><font size="2">, </font></p> <p>the @uid is actually the GUID that is provided to the user. when I try to pass that to a static Datasource as through a querystring or session variable it treats it as a string and prevents it from being used as a comparison to a GUID. so I thought of doing it the way I have it down below. </p> <p>Over all if someone can tell me how to do it my initial way please do. But if not can someone explain how to fix the way I have it below?</p> <p>&nbsp;</p> <p>&nbsp;Error &quot;Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.&quot;</p> <p><font size="2">&nbsp;</p> <p></font><font color="#0000ff" size="2">protected</font><font size="2"> </font><font color="#0000ff" size="2">void</font><font size="2"> Page_Load(</font><font color="#0000ff" size="2">object</font><font size="2"> sender, </font><font color="#008080" size="2">EventArgs</font><font size="2"> e)</p> <p>{</p> <blockquote> <p></font><font color="#0000ff" size="2">string</font><font size="2"> uname = Page.User.Identity.Name;</p> <p></font><font color="#008080" size="2">MembershipUser</font><font size="2"> user = </font><font color="#008080" size="2">Membership</font><font size="2">.GetUser(uname);</p> <p></font><font color="#0000ff" size="2">if</font><font size="2"> (uname != </font> <font color="#800000" size="2">&quot;&quot;</font><font size="2">)</p> <p>{</p> <p></font><font color="#008080" size="2">Guid</font><font size="2"> userId = (</font><font color="#008080" size="2">Guid</font><font size="2">)user.ProviderUserKey;</p> <p></font><font color="#008080" size="2">SqlConnection</font><font size="2"> cnn = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">SqlConnection</font><font size="2">(</font><font color="#800000" size="2">&quot;Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\jobs.mdf;Integrated Security=True;User Instance=True&quot;</font><font size="2">);</p> <p></font><font color="#008080" size="2">SqlDataAdapter</font><font size="2"> da = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">SqlDataAdapter</font><font size="2">(</font><font color="#800000" size="2">&quot;SELECT resume_file_size, resume_file_type, resume_name, date_uploaded, resume_file_name, viewedcount FROM resumes WHERE (uid = @uid)&quot;</font><font size="2">, cnn);</p> <p>da.SelectCommand.Parameters.Add(</font><font color="#800000" size="2">&quot;@uid&quot;</font><font size="2">, </font><font color="#008080" size="2">SqlDbType</font><font size="2">.UniqueIdentifier).Value = userId;</p> <p></font><font color="#008080" size="2">DataSet</font><font size="2"> ds = </font> <font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">DataSet</font><font size="2">();</p> <p>da.Fill(ds, </font><font color="#800000" size="2">&quot;resumes&quot;</font><font size="2">);</p> <p>Repeater1.DataSource = ds.Tables[</font><font color="#800000" size="2">&quot;resumes&quot;</font><font size="2">];</p> <p>Repeater1.DataBind();</p> <p>}</p> </blockquote> <p>}</p> </font> <p>&nbsp;</p> <font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">Repeater</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;Repeater1&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;&gt;</font><font color="#0000ff" size="2"></p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">HeaderTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">table</font><font size="2"> </font><font color="#ff0000" size="2">cols</font><font color="#0000ff" size="2">=3&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">tr</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <blockquote> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">td</font><font size="2"> </font><font color="#ff0000" size="2">colspan</font><font color="#0000ff" size="2">=3&gt;</p> </font><font size="2"> <blockquote> <p>Your Resumes currently on our system.</p> </blockquote> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">td</font><font color="#0000ff" size="2">&gt;</p> </blockquote> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">tr</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p>&nbsp;</p> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">HeaderTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">ItemTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">tr</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <blockquote> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">td</font><font size="2"> </font><font color="#ff0000" size="2">align</font><font color="#0000ff" size="2">=left&gt;</p> </blockquote> </font><font size="2"> <blockquote> <blockquote> <p>&lt;% Eval(</font><font color="#800000" size="2">&quot;resume_file_name&quot;</font><font size="2">); %&gt;</p> </blockquote> </blockquote> <blockquote> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">td</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">td</font><font size="2"> </font><font color="#ff0000" size="2">align</font><font color="#0000ff" size="2">=right&gt;</p> </blockquote> </font><font size="2"> <blockquote> <blockquote> <p>Last Updated: &lt;% Eval(</font><font color="#800000" size="2">&quot;date_uploaded&quot;</font><font size="2">); %&gt;</p> </blockquote> </blockquote> <blockquote> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">td</font><font color="#0000ff" size="2">&gt;</p> </blockquote> </font> 2006-11-25T20:19:18-05:001476481http://forums.asp.net/p/1048637/1476481.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." I wouldn't suggest doing it this way, but for the sake of brevity for you, the solution to this problem is to change your code from &lt;% Eval(&quot;date_uploaded&quot;); %&gt; to &lt;%# Eval(&quot;date_uploaded&quot;) %&gt;. The &lt;% %&gt; syntax is effectively a wrapper for Response.Write, so it doesn't allow the use of Eval, XPath, or Bind. The &lt;%# %&gt; syntax is only called when the parent control is being data bound, therefore it allows Eval.<br> 2006-11-26T01:02:23-05:001479376http://forums.asp.net/p/1048637/1479376.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>Your suggestion worked for that specific issue Thank you for that.</p> <p>but after running into that I came up with a much larger issue.</p> <p>With the repeater I do not have delete,Update options... This is the reason I initially wanted to go with either a gridview or Details view but the problem I had with that is when I create the sql query to pull the info from the database I need to use the Uniqueidentifier field for a comparison. The problem I am having with that is the SQLDataSource does not allow for the UniqueIdentifier to be used. It keeps telling me something to the extent of.. &quot;Cannot cast UniqueIdentifier as String&quot; </p> <p>&nbsp;Do you know how I can use a Gridview or Detailsview with using a uniqueIdentifier as a comparison in the SQL Query?</p> <p>I hope that makes sense.....</p> 2006-11-28T19:50:22-05:001479396http://forums.asp.net/p/1048637/1479396.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>Disregard that last message I figured out how to allow a gridview </p> <font size="2"> <p></font><font color="#008080" size="2">SqlConnection</font><font size="2"> cn = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">SqlConnection</font><font size="2">(</font><font color="#800000" size="2">&quot;Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\jobs.mdf;Integrated Security=True;User Instance=True&quot;</font><font size="2">);</p> <p></font><font color="#008080" size="2">SqlDataAdapter</font><font size="2"> SQLda = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">SqlDataAdapter</font><font size="2">(</font><font color="#800000" size="2">&quot;SELECT date_uploaded, resume_name, viewedcount FROM resumes WHERE (uid = @uid)&quot;</font><font size="2">, cn);</p> <p>SQLda.SelectCommand.Parameters.Add(</font><font color="#800000" size="2">&quot;@uid&quot;</font><font size="2">, </font><font color="#008080" size="2">SqlDbType</font><font size="2">.UniqueIdentifier).Value = userId;</p> <p></font><font color="#008080" size="2">DataSet</font><font size="2"> SQLds = </font> <font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">DataSet</font><font size="2">();</p> <p>SQLda.Fill(SQLds, </font><font color="#800000" size="2">&quot;resumes&quot;</font><font size="2">);</p> <p>GridView1.DataSource = SQLds.Tables[</font><font color="#800000" size="2">&quot;resumes&quot;</font><font size="2">];</p> <p>GridView1.DataBind();</p> </font> 2006-11-28T20:09:27-05:001492217http://forums.asp.net/p/1048637/1492217.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>When I wanted to relate two dropdown list , I got same errors ....Then I tried using using usercontrol for the related dropdownlist and added this user control to details view and binded the public properties of user control in html . Things work fine.... </p> <p>You can get detailed writeup in http://aspdotnetprojects.googlepages.com/home </p> <p>&nbsp;</p> <p>Feedback appreciated </p> <p>Bhat Np </p> <p>MCAD</p> <p>bhatnp@gmail.com/bhatnp@yahoo.com</p> 2006-12-10T13:14:31-05:001502630http://forums.asp.net/p/1048637/1502630.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>Bhat:</p> <p>I have run into the same error with two dropdownlists in a fromview. After going through your solution on the URL you reference, I couldn't determine where to add the code in my application to get and set the properties you describe, step 5, does this go in a new class, the .ascx file codebehind, where?</p> <p class="MsoNormal" style="">Add two public <span class="GramE">properties<span style="">&nbsp; </span>for</span> country and city&nbsp;<span style="">&nbsp;</span></p> <p class="MsoNormal" style=""><span style=""></span>(For ex <span style="font-size:10pt; font-family:'Courier New'"> <span style="">&nbsp;</span><span style="color:blue">Public</span> <span style="color:blue"> Property</span> country() <span style="color:blue">As</span> <span style="color:blue"> String</span></span></p> <p class="MsoNormal" style=""><span style="font-size:10pt; font-family:'Courier New'"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color:blue">Get</span></span></p> <p class="MsoNormal" style=""><span style="font-size:10pt; font-family:'Courier New'"><span style="color:blue"></span></span><span style="font-size:10pt; font-family:'Courier New'"><span style="">&nbsp;&nbsp;&nbsp;</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color:blue">Return</span> CountryDropDownList.SelectedValue</span></p> <p class="MsoNormal" style=""><span style="font-size:10pt; font-family:'Courier New'"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color:blue">End</span> <span style="color:blue">Get</span></span></p> <p class="MsoNormal" style=""><span style="font-size:10pt; font-family:'Courier New'"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color:blue">Set</span>(<span style="color:blue">ByVal</span> value <span style="color:blue">As</span> <span style="color:blue">String</span>)</span></p> <p class="MsoNormal" style=""><span style="font-size:10pt; font-family:'Courier New'"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>countryDropDownList.SelectedValue = value</span></p> <p class="MsoNormal" style=""><span style="font-size:10pt; font-family:'Courier New'"></span><span style="font-size:10pt; font-family:'Courier New'"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color:blue">End</span> <span style="color:blue">Set</span></span></p> <p class="MsoNormal" style="margin-left:0.25in"><span style="font-size:10pt; font-family:'Courier New'"><span style="">&nbsp;&nbsp; </span><span style="color:blue">End</span> <span style="color:blue">Property)</span></span></p> <p>Thank you for your help!</p> <p class="MsoNormal" style="margin-left:0.25in"><span style="font-size:10pt; font-family:'Courier New'"><span style="color:blue"></span></span>&nbsp;</p> <p class="MsoNormal" style="margin-left:0.25in"><span style="font-size:10pt; font-family:'Courier New'"><span style="color:blue"></span></span>&nbsp;</p> 2006-12-19T21:23:08-05:001502701http://forums.asp.net/p/1048637/1502701.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>Bhat:</p> <p>In my code, I added the set and get property code to the code behind page of the control, Is this correct?</p> <p>Now the control shows up in my form view edititem template but I'm not clear on how you bind to the control. In my case. The control has two dropdownlists as you described in the example. If I click on the smart tag and click edit databindings how do I bind to BOTH the city and country? Can you add more than one field in a binding as your example seems to state? </p> <p>Thank you for your help.</p> 2006-12-19T22:14:35-05:001509640http://forums.asp.net/p/1048637/1509640.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." go to html view and in UCL tag set the 2 public properties &lt;%bind syntax <br> 2006-12-27T10:24:30-05:001511105http://forums.asp.net/p/1048637/1511105.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;Bhat:&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;&nbsp;&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;Thanks for your reply and assistance. I think I'm doing everything you have described but I must not be binding the user control correctly. Correct me if I'm wrong but the user control can only be bound to one field? The user control created has two fields, city and country?&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;&nbsp;&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;Is there a way to bind both? My normal binding for each would be &lt;%# bind(&quot;country&quot;) %&gt; &lt;%# bind(&quot;city&quot;) %&gt;&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;&nbsp;&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;In my webform, I'm using two fields, Contractor and JobTitle. The various contractors can have several to no child job titles. The same type of parent, child relationship as country and city.&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;&nbsp;&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;Here is the code I'm using...&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;&nbsp;&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;This is the <strong>user control</strong>.... DisplayJobTitle.ascx&nbsp;&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;<pre class="prettyprint">&lt;%@ Control Language=&quot;C#&quot; ClassName=&quot;JobTitles&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;DisplayJobTitle.ascx.cs&quot; Inherits=&quot;DisplayJobTitle&quot; %&gt; &lt;asp:DropDownList ID=&quot;ddl_Contractors&quot; runat=&quot;server&quot; DataSourceID=&quot;ods_Contractors&quot; DataTextField=&quot;ShortDescription&quot; DataValueField=&quot;ContractorID&quot; AutoPostBack=&quot;True&quot;&gt; &lt;/asp:DropDownList&gt; / &lt;asp:DropDownList ID=&quot;ddl_JobTitles&quot; runat=&quot;server&quot; DataSourceID=&quot;ods_JobTitles&quot; DataTextField=&quot;JobTitle&quot; DataValueField=&quot;JobTitleID&quot;&gt; &lt;/asp:DropDownList&gt;&lt;asp:ObjectDataSource ID=&quot;ods_JobTitles&quot; runat=&quot;server&quot; OldValuesParameterFormatString=&quot;original_{0}&quot; SelectMethod=&quot;GetJobTitlesByContractorID&quot; TypeName=&quot;BMSDataSetTableAdapters.JobTitlesTableAdapter&quot;&gt; &lt;SelectParameters&gt; &lt;asp:ControlParameter ControlID=&quot;ddl_Contractors&quot; Name=&quot;contractorID&quot; PropertyName=&quot;SelectedValue&quot; Type=&quot;Decimal&quot; /&gt; &lt;/SelectParameters&gt; &lt;/asp:ObjectDataSource&gt; &lt;asp:ObjectDataSource ID=&quot;ods_Contractors&quot; runat=&quot;server&quot; OldValuesParameterFormatString=&quot;original_{0}&quot; SelectMethod=&quot;GetContractors&quot; TypeName=&quot;BMSDataSetTableAdapters.ContractorsTableAdapter&quot;&gt; &lt;/asp:ObjectDataSource&gt;</pre>&nbsp;<BR>This is the <STRONG>user control code behind page</STRONG>.... DisplayJobTitle ascx.cs&nbsp;&lt;/div&gt; &lt;div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"&gt;<pre class="prettyprint"><SPAN class=kwd>using</SPAN> System; <SPAN class=kwd>using</SPAN> System.Data; <SPAN class=kwd>using</SPAN> System.Configuration; <SPAN class=kwd>using</SPAN> System.Collections; <SPAN class=kwd>using</SPAN> System.Web; <SPAN class=kwd>using</SPAN> System.Web.Security; <SPAN class=kwd>using</SPAN> System.Web.UI; <SPAN class=kwd>using</SPAN> System.Web.UI.WebControls; <SPAN class=kwd>using</SPAN> System.Web.UI.WebControls.WebParts; <SPAN class=kwd>using</SPAN> System.Web.UI.HtmlControls; <SPAN class=kwd>public</SPAN> partial <SPAN class=kwd>class</SPAN> DisplayJobTitle : System.Web.UI.UserControl { <SPAN class=kwd>public string</SPAN> contractor { <SPAN class=kwd>get</SPAN> { <SPAN class=kwd>return</SPAN> ddl_Contractors.SelectedValue.ToString(); } <SPAN class=kwd>set</SPAN> { ddl_Contractors.SelectedValue = <SPAN class=kwd>value</SPAN>; } } <SPAN class=kwd>public string</SPAN> jobTitle { <SPAN class=kwd>get</SPAN> { <SPAN class=kwd>return</SPAN> ddl_JobTitles.SelectedValue.ToString(); } <SPAN class=kwd>set</SPAN> { ddl_JobTitles.SelectedValue = <SPAN class=kwd>value</SPAN>; } } } </pre>&nbsp;<BR>This is <STRONG>formview within an edititemtemplate on my webform</STRONG> that is trying to do the cascadding dropdown and be bound....Staff_Edit.aspx&lt;/div&gt; &lt;div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"&gt;<FONT color=#0000ff size=2></FONT>&nbsp;&lt;/div&gt; &lt;div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"&gt;&nbsp;<pre class="prettyprint">&lt;<SPAN class=tag>asp:FormView</SPAN><SPAN class=attr> ID=</SPAN><SPAN class=attrv>"FormView_Descriptors"</SPAN><SPAN class=attr> DataKeyNames=</SPAN><SPAN class=attrv>"profileid"</SPAN><SPAN class=attr> runat=</SPAN><SPAN class=attrv>"server"</SPAN><SPAN class=attr> DataSourceID=</SPAN><SPAN class=attrv>"ods_Staff_Descriptors"</SPAN> <SPAN class=attr>DefaultMode=</SPAN><SPAN class=attrv>"Edit"</SPAN><SPAN class=attr> OnItemCreated=</SPAN><SPAN class=attrv>"FormView_Descriptors_ItemCreated"</SPAN><SPAN class=attr> OnItemUpdated=</SPAN><SPAN class=attrv>"FormView_Descriptors_ItemUpdated"</SPAN>&gt; &lt;<SPAN class=tag>EditItemTemplate</SPAN>&gt; Company/Title: &lt;<SPAN class=tag>uc1:DisplayJobTitle</SPAN><SPAN class=attr> ID=</SPAN><SPAN class=attrv>"DisplayJobTitle1"</SPAN><SPAN class=attr> runat=</SPAN><SPAN class=attrv>"server"</SPAN><SPAN class=attr> Visible=</SPAN><SPAN class=attrv>'<SPAN class=dir>&lt;%#</SPAN> Bind("contractorID") <SPAN class=dir>%&gt;</SPAN>'</SPAN> /&gt; &lt;<SPAN class=tag>asp:Button</SPAN><SPAN class=attr> ID=</SPAN><SPAN class=attrv>"btn_UpdateDescriptors"</SPAN><SPAN class=attr> runat=</SPAN><SPAN class=attrv>"server"</SPAN><SPAN class=attr> CommandName=</SPAN><SPAN class=attrv>"Update"</SPAN><SPAN class=attr> Text=</SPAN><SPAN class=attrv>"Save"</SPAN> /&gt; &lt;/<SPAN class=tag>EditItemTemplate</SPAN>&gt; &lt;/<SPAN class=tag>asp:FormView</SPAN>&gt;</pre>&nbsp;<strong>I get this Error: <u>InvalidCastException was unhandled by user code. Specified cast is not valid</u></strong>&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;<strong><u></u></strong>&nbsp;&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;ERROR is from this line.. &lt;uc1:DisplayJobTitle ID=&quot;DisplayJobTitle1&quot; runat=&quot;server&quot; Visible='&lt;%# Bind(&quot;contractorID&quot;) %&gt;' /&gt;.. the usercontrol in the webform&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;&nbsp;&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;I would assume it's because the binding isn't working...?&lt;/div&gt; &lt;div style=&quot;FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif&quot;&gt;&nbsp;&lt;/div&gt; 2006-12-28T14:21:24-05:001511195http://forums.asp.net/p/1048637/1511195.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>When you say &quot;HTML&quot; view do you mean the Source view in Visual Studio?</p> <p>I tried binding the two dropdownlists in the user control. ( see code below) but still get the... Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control, ERROR.</p> <p>Is this how you were suggesting to bind the&nbsp;fields?</p> <pre class="prettyprint">&lt;%@ Control Language=&quot;C#&quot; ClassName=&quot;JobTitles&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;DisplayJobTitle.ascx.cs&quot; Inherits=&quot;DisplayJobTitle&quot; %&gt; &lt;asp:DropDownList ID=&quot;ddl_Contractors&quot; runat=&quot;server&quot; DataSourceID=&quot;ods_Contractors&quot; DataTextField=&quot;ShortDescription&quot; DataValueField=&quot;ContractorID&quot; <strong>SelectedValue=</strong><strong>'&lt;%# Bind(&quot;ContractorID&quot;) %&gt;</strong>' AutoPostBack=&quot;True&quot;&gt; &lt;/asp:DropDownList&gt; / &lt;asp:DropDownList ID=&quot;ddl_JobTitles&quot; runat=&quot;server&quot; DataSourceID=&quot;ods_JobTitles&quot; DataTextField=&quot;JobTitle&quot; DataValueField=&quot;JobTitleID&quot; <strong>SelectedValue=</strong><strong>'&lt;%# Bind(&quot;JobTitleID&quot;) %&gt;</strong>'&gt; &lt;/asp:DropDownList&gt;&lt;asp:ObjectDataSource ID=&quot;ods_JobTitles&quot; runat=&quot;server&quot; OldValuesParameterFormatString=&quot;original_{0}&quot; SelectMethod=&quot;GetJobTitlesByContractorID&quot; TypeName=&quot;BMSDataSetTableAdapters.JobTitlesTableAdapter&quot;&gt; &lt;SelectParameters&gt; &lt;asp:ControlParameter ControlID=&quot;ddl_Contractors&quot; Name=&quot;contractorID&quot; PropertyName=&quot;SelectedValue&quot; Type=&quot;Decimal&quot; /&gt; &lt;/SelectParameters&gt; &lt;/asp:ObjectDataSource&gt; &lt;asp:ObjectDataSource ID=&quot;ods_Contractors&quot; runat=&quot;server&quot; OldValuesParameterFormatString=&quot;original_{0}&quot; SelectMethod=&quot;GetContractors&quot; TypeName=&quot;BMSDataSetTableAdapters.ContractorsTableAdapter&quot;&gt; &lt;/asp:ObjectDataSource&gt;</pre>&nbsp; 2006-12-28T15:22:05-05:001516620http://forums.asp.net/p/1048637/1516620.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>Can anyone or Bhat&nbsp;give me and example of binding the two public properties to the UC1 tag? </p> <p>Here is my user control tag..</p> <p>&nbsp;</p> 2007-01-03T15:12:03-05:001516625http://forums.asp.net/p/1048637/1516625.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>Can anyone or Bhat&nbsp;give me and example of setting the&nbsp;two public properties to the UC1 tag? </p> <p>Here is my user control tag..</p> <p>&lt;<span class="tag">uc1:DisplayJobTitle</span><span class="attr"> ID=</span><span class="attrv">&quot;DisplayJobTitle1&quot;</span><span class="attr"> runat=</span><span class="attrv">&quot;server&quot;</span> /&gt; </p> <p>Is this the same as binding, I don't understand what you mean?</p> &nbsp; 2007-01-03T15:13:40-05:001516938http://forums.asp.net/p/1048637/1516938.aspx/1?Re+Error+Data+binding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Data binding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>There are&nbsp; three&nbsp;items I wanted to point out that Bhat doesn't mation on his solution on the website above.</p> <p>1. In the code behind page where you set the user control properties, you must import the namespace System.ComponetModel...</p> <p><font color="#0000ff" size="2">using</font><font size="2"> System.ComponentModel;</font></p> <p><font size="2">2. You must set the two properties to Bindable true...</font>&nbsp;</p> <pre class="prettyprint">[Bindable(true)] public string Contractor { get { return ddl_Contractors.SelectedValue.ToString(); } set { ddl_Contractors.SelectedValue = value; } }</pre><pre class="prettyprint">&nbsp;</pre>&nbsp;&nbsp;3. The properties <STRONG>DO NOT</STRONG> get picked up in the binding wizard, to bind the two properties you must go to source view of the user control tag and type in the property name and do the bind by hand code. In my case the first property is Contractor and the second property is Subtitled. Like so...</PRE><pre class="prettyprint">&lt;<SPAN class=tag>uc1:DisplayJobTitle</SPAN><SPAN class=attr> ID=</SPAN><SPAN class=attrv>"DisplayJobTitle1"</SPAN><SPAN class=attr> Contractor=</SPAN><SPAN class=attrv>'<SPAN class=dir>&lt;%#</SPAN> Bind("contractors") <SPAN class=dir>%&gt;</SPAN>'</SPAN><SPAN class=attr> JobTitle=</SPAN><SPAN class=attrv>'<SPAN class=dir>&lt;%#</SPAN> Bind("Subtitled") <SPAN class=dir>%&gt;</SPAN>'</SPAN><SPAN class=attr> runat=</SPAN><SPAN class=attrv>"server"</SPAN> /&gt;</pre> <p>Hopefully Bhat will update his example to include these three items for a more conclusive solution example.</p> 2007-01-03T18:09:24-05:001517585http://forums.asp.net/p/1048637/1517585.aspx/1?Re+Error+Data+binding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Data binding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>Thanks ..</p> <p>properties <strong>for the user control is as under in user control</strong></p> <font size="2"> <p>&lt;System.ComponentModel.DesignerSerializationVisibility(ComponentModel.DesignerSerializationVisibility.Visible), System.ComponentModel.Bindable(</font><font color="#0000ff" size="2">True</font><font size="2">), System.ComponentModel.Browsable(</font><font color="#0000ff" size="2">True</font><font size="2">), System.ComponentModel.SettingsBindable(</font><font color="#0000ff" size="2">True</font><font size="2">)&gt; _</p> <p></font><font color="#0000ff" size="2">Public</font><font size="2"> </font><font color="#0000ff" size="2">Property</font><font size="2"> Equipmenttype() </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">Get</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">Return</font><font size="2"> EquipmemtTypeDropDownList.SelectedValue</p> <p></font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Get</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">Set</font><font size="2">(</font><font color="#0000ff" size="2">ByVal</font><font size="2"> value </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2">)</p> <p>EquipmemtTypeDropDownList.SelectedValue = value</p> <p></font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Set</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Property</p> </font><font size="2"> <p>&lt;System.ComponentModel.Bindable(</font><font color="#0000ff" size="2">True</font><font size="2">), System.ComponentModel.Browsable(</font><font color="#0000ff" size="2">True</font><font size="2">)&gt; _</p> <p></font><font color="#0000ff" size="2">Public</font><font size="2"> </font><font color="#0000ff" size="2">Property</font><font size="2"> equipmentModel() </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">Get</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">Return</font><font size="2"> EquipmentModelDropDownList.SelectedValue</p> <p></font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Get</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">Set</font><font size="2">(</font><font color="#0000ff" size="2">ByVal</font><font size="2"> value </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2">)</p> <p>EquipmentModelDropDownList.SelectedValue = value</p> <p></font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Set</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Property</p> </font> <p><strong>When you used the user control in main aspx page , you have to bind the user control's properties in the following way</strong> </p> <p><font color="#0000ff" size="2">&nbsp;</p> <p>&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">TemplateField</font><font size="2"> </font><font color="#ff0000" size="2">HeaderText</font><font color="#0000ff" size="2">=&quot;Equipment Data&quot;&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">InsertItemTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">uc1</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">EquipmentUserControl</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;EquipmentUserControl1&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Equipmenttype</font><font color="#0000ff" size="2">='</font><font size="2">&lt;%# bind(&quot;EquipmentType&quot;) %&gt;</font><font color="#0000ff" size="2">'</font><font size="2"> </font><font color="#ff0000" size="2">equipmentModel</font><font color="#0000ff" size="2">='</font><font size="2">&lt;%# bind(&quot;Equipmentname&quot;) %&gt;</font><font color="#0000ff" size="2">'</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">InsertItemTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">TemplateField</font><font color="#0000ff" size="2">&gt;</p> </font> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>Sorry for delay in replying........</p> <p>&nbsp;</p> <p>Regards</p> <p>bhat</p> 2007-01-04T02:59:41-05:002679914http://forums.asp.net/p/1048637/2679914.aspx/1?Re+Error+Data+binding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Data binding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>&nbsp;This thread saved my life!!!! I was fighting with this problem for over a month!!!!</p> <p>&nbsp;Thank you all! <br> </p> 2008-10-13T18:33:05-04:002955311http://forums.asp.net/p/1048637/2955311.aspx/1?Re+Error+Data+binding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Data binding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>Yes I would like to second that... Thank you!&nbsp; I just ran into this same exact problem and had already wasted several hours trying to come up with a solution.&nbsp; This worked like a charm and took about 10 minutes to implement.</p> 2009-02-20T16:06:25-05:003068673http://forums.asp.net/p/1048637/3068673.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>&nbsp;Hello There,</p> <p>&nbsp;From this Post i have Found that&nbsp; for error Error &quot;Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.&quot; has a Second cause also First Cause I have Discuss and Solved you Can find it by following link.Please Share Other cause and Solution there.Thank you</p> <a href="http://dotnet-magic.blogspot.com/2009/04/databinding-method-such-as-evalxpath.html" title="http://dotnet-magic.blogspot.com/2009/04/databinding-method-such-as-evalxpath.html" target="_blank">http://dotnet-magic.blogspot.com/2009/04/databinding-method-such-as-evalxpath.html</a> 2009-04-07T08:38:19-04:003447122http://forums.asp.net/p/1048637/3447122.aspx/1?Re+Error+Databinding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&lt;asp:Repeater ID=&quot;postCategoryRepeater&quot; runat=&quot;server&quot; DataSourceID=&quot;postCategoryDataSource&quot;&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ItemTemplate&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;h1&gt;&lt;%# DataBinder.Eval(Container.DataItem, &quot;Name&quot;) %&gt;&lt;/h1&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;asp:Repeater ID=&quot;postRepeater&quot; runat=&quot;server&quot; DataSource='&lt;%# DataBinder.Eval(Container.DataItem, &quot;PostCollection&quot;) %&gt;'&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ItemTemplate&gt;&nbsp;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Test&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/ItemTemplate&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/asp:Repeater&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/ItemTemplate&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/asp:Repeater&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;data:PostCategoryDataSource ID=&quot;postCategoryDataSource&quot; runat=&quot;server&quot; SelectMethod=&quot;GetAll&quot; EnableDeepLoad=&quot;true&quot;&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;DeepLoadProperties Method=&quot;IncludeChildren&quot; Recursive=&quot;false&quot;&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Types&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;data:PostCategoryProperty Name=&quot;PostCollection&quot; /&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Types&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/DeepLoadProperties&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/data:PostCategoryDataSource&gt;&lt;/div&gt; &lt;div style=&quot;position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;&quot; id=&quot;_mcePaste&quot;&gt;&lt;/div&gt; <p>&lt;p&gt;</p> <p>I got this post very helpful</p> <p></p> <p>&lt;asp:Repeater ID=&quot;postCategoryRepeater&quot; runat=&quot;server&quot; DataSourceID=&quot;postCategoryDataSource&quot;&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ItemTemplate&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;h1&gt;&lt;%# DataBinder.Eval(Container.DataItem, &quot;Name&quot;) %&gt;&lt;/h1&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;asp:Repeater ID=&quot;postRepeater&quot; runat=&quot;server&quot; DataSource='&lt;%# DataBinder.Eval(Container.DataItem, &quot;PostCollection&quot;) %&gt;'&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ItemTemplate&gt;&nbsp;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Test</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/ItemTemplate&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/asp:Repeater&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/ItemTemplate&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/asp:Repeater&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;data:PostCategoryDataSource ID=&quot;postCategoryDataSource&quot; runat=&quot;server&quot; SelectMethod=&quot;GetAll&quot; EnableDeepLoad=&quot;true&quot;&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;DeepLoadProperties Method=&quot;IncludeChildren&quot; Recursive=&quot;false&quot;&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Types&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;data:PostCategoryProperty Name=&quot;PostCollection&quot; /&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Types&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/DeepLoadProperties&gt;</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/data:PostCategoryDataSource&gt;</p> <p><br> </p> <p></p> <p>&lt;p&gt;</p> 2009-10-08T07:01:25-04:003474426http://forums.asp.net/p/1048637/3474426.aspx/1?Re+Error+Data+binding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Data binding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>I have a different situation.&nbsp; I am using Visual Web Developer 2008 and coding in Visual Basic.&nbsp;&nbsp;My page was working prior to a change that I made to one of the tables that I use in a dropdownlsit.</p> <p>&nbsp;</p> <p>I change the table so that the ID is alphanumeric and not an integer.&nbsp; I thought&nbsp;I had recompiled and changed all the code.&nbsp; I cannot find why I am now getting this error.&nbsp; Here is my code for the DDL:</p> <p>&nbsp;</p> <pre class="prettyprint">&lt;asp:DropDownList ID=&quot;ddlLeadType&quot; runat=&quot;server&quot; BackColor=&quot;LightSalmon&quot; DataSourceID=&quot;odsLeadType&quot; DataTextField=&quot;LeadType&quot; DataValueField=&quot;LeadTypeID&quot; SelectedValue='&lt;%# Bind(&quot;LeadType&quot;) %&gt;' Width=&quot;150px&quot;&gt; &lt;/asp:DropDownList&gt;</pre> <p><br> Thanks for your help!!&nbsp;</p> 2009-10-23T19:26:38-04:003474504http://forums.asp.net/p/1048637/3474504.aspx/1?Re+Error+Data+binding+methods+such+as+Eval+XPath+and+Bind+can+only+be+used+in+the+context+of+a+databound+control+Re: Error "Data binding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control." <p>I found the solution ... </p> <p>In the Dataset file, &lt;Dataset&gt;.xsd, it was showing two fields for the&nbsp;lead&nbsp;type.&nbsp; The LeadType was the old field as an integer.&nbsp; The&nbsp;LeadType1 was the new field as a string.&nbsp; Once I changed the LeadType to be a string, then everything worked correctly.</p> <p>&nbsp;</p> <p>FYI to anyone who might have this situationn.&nbsp;</p> 2009-10-23T20:27:40-04:00