Update Databound controls within a DetailsView TemplateField

G

Guest

This is driving me nuts, it is such a simply thing to do but i cannot for the
life of me work out how you are suposed to do it. I want to update the data
in DropDownListB based on what is selected in DropDownListA. I am not trying
to do anything fancy with AJAX, i am happy to use Post Backs. If it were two
controls just on the page then i would simply specify a control parameter for
the SelectCommand of the SQLDataSource control which the DropDownListB is
bound to. However the DDLs are in seperate TemplateFields that are in a
DetailsView control so i can't put the SQLDataSource control anywhere on the
page where DropDownListB can see it and It can see DropDownListA. It has
just occured to me that i could put them both in the same TemplateField but
this is not ideal. I have tried a million ways to do this all to no avail,
i would list them but it would make this post about 2000 words long.
 
G

Guest

Right i have tried the both DDL controls and the SQLDataSource in the same
TemplateField technique and i bump up against the same error as i have been
getting with everything i try as follows

I think the error has something to do with the point at which the databound
controls are refreshed but the error is so vague i can't really get to the
bottom of it.

Server Error in '/Portal' Application.
Databinding methods such as Eval(), XPath(), and Bind() can only be used in
the context of a databound control.
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.InvalidOperationException: Databinding methods
such as Eval(), XPath(), and Bind() can only be used in the context of a
databound control.

Source Error:

[No relevant source lines]


Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\portal\3fee1574\f20094c7\App_Web_xdk9eypg.0.cs Line: 0

Stack Trace:

[InvalidOperationException: Databinding methods such as Eval(), XPath(), and
Bind() can only be used in the context of a databound control.]
System.Web.UI.Page.GetDataItem() +1996866
ASP.complaints_aspx.__DataBinding__control350(Object sender, EventArgs e)
in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\portal\3fee1574\f20094c7\App_Web_xdk9eypg.0.cs:0
System.Web.UI.Control.OnDataBinding(EventArgs e) +99
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +11
System.Web.UI.WebControls.ListControl.PerformSelect() +31
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +26
System.Web.UI.Control.PreRenderRecursiveInternal() +77
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
 
G

Guest

Thanks very much, that's great. I have been trying to do this simple thing
for a day and a half and i was about to commit an act of extreme violence
against my computer. I think i may just go back to using PHP, it's so much
easier ;-)


Phillip Williams said:
http://www.webswapp.com/codesamples/aspnet20/dependentlists/default.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


clickon said:
Right i have tried the both DDL controls and the SQLDataSource in the same
TemplateField technique and i bump up against the same error as i have been
getting with everything i try as follows

I think the error has something to do with the point at which the databound
controls are refreshed but the error is so vague i can't really get to the
bottom of it.

Server Error in '/Portal' Application.
Databinding methods such as Eval(), XPath(), and Bind() can only be used in
the context of a databound control.
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.InvalidOperationException: Databinding methods
such as Eval(), XPath(), and Bind() can only be used in the context of a
databound control.

Source Error:

[No relevant source lines]


Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\portal\3fee1574\f20094c7\App_Web_xdk9eypg.0.cs Line: 0

Stack Trace:

[InvalidOperationException: Databinding methods such as Eval(), XPath(), and
Bind() can only be used in the context of a databound control.]
System.Web.UI.Page.GetDataItem() +1996866
ASP.complaints_aspx.__DataBinding__control350(Object sender, EventArgs e)
in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\portal\3fee1574\f20094c7\App_Web_xdk9eypg.0.cs:0
System.Web.UI.Control.OnDataBinding(EventArgs e) +99
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +11
System.Web.UI.WebControls.ListControl.PerformSelect() +31
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +26
System.Web.UI.Control.PreRenderRecursiveInternal() +77
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
 
G

Guest

You are welcome. I get emails from many people who had similar experiences
regarding this issue. Hope that makes you feels a bit better ;-)

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


clickon said:
Thanks very much, that's great. I have been trying to do this simple thing
for a day and a half and i was about to commit an act of extreme violence
against my computer. I think i may just go back to using PHP, it's so much
easier ;-)


Phillip Williams said:
http://www.webswapp.com/codesamples/aspnet20/dependentlists/default.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


clickon said:
Right i have tried the both DDL controls and the SQLDataSource in the same
TemplateField technique and i bump up against the same error as i have been
getting with everything i try as follows

I think the error has something to do with the point at which the databound
controls are refreshed but the error is so vague i can't really get to the
bottom of it.

Server Error in '/Portal' Application.
Databinding methods such as Eval(), XPath(), and Bind() can only be used in
the context of a databound control.
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.InvalidOperationException: Databinding methods
such as Eval(), XPath(), and Bind() can only be used in the context of a
databound control.

Source Error:

[No relevant source lines]


Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\portal\3fee1574\f20094c7\App_Web_xdk9eypg.0.cs Line: 0

Stack Trace:

[InvalidOperationException: Databinding methods such as Eval(), XPath(), and
Bind() can only be used in the context of a databound control.]
System.Web.UI.Page.GetDataItem() +1996866
ASP.complaints_aspx.__DataBinding__control350(Object sender, EventArgs e)
in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\portal\3fee1574\f20094c7\App_Web_xdk9eypg.0.cs:0
System.Web.UI.Control.OnDataBinding(EventArgs e) +99
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +11
System.Web.UI.WebControls.ListControl.PerformSelect() +31
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +26
System.Web.UI.Control.PreRenderRecursiveInternal() +77
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
 
G

Guest

right second question, you code uses the e object that you have to put in
every event procedure. I have never been able to work out what it is, what
it does, why it is there and what you are suposed to do with it so i am
finding your code a bit hard to follow. would you mind explaining it to me.
Forgive my ignorance, i have only been learning ASP.net for a few weeks and
all the books i have read have just never atempted an explanation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top