I have a question, is there a "standard" way to access the current data item in the codebehind of a dynamic data page that has the ID in the querystring? (I could get the ID from the querystring and look it up manually but I'm just wondering if there's a
built-in function for it so I don't hit the database again for something that's already been looked up?)
I'm customizing Details.aspx so that it shows some child records in addition to the fields on the current record. (It's a response to a survey - I'm adding the list of questions with the answer for each question.)
I tried something like this but I got an error, Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
QuestionListUserControl questions = UpdatePanel1.FindControl("QuestionList") as QuestionListUserControl;
questions.DataSource = (GetDataItem() as SurveyResponse).SurveyResponseAnswers;
questions.DataBind();
}
}
Hi Tmmycat, you cannot get access to the current value excep in OnDataBound event then you call GetDataItem() method on the page to get the current value.
Dynamic Data 4
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Member
207 Points
139 Posts
How to access the data item of the current page?
Nov 22, 2010 09:53 AM|tmmycat|LINK
I have a question, is there a "standard" way to access the current data item in the codebehind of a dynamic data page that has the ID in the querystring? (I could get the ID from the querystring and look it up manually but I'm just wondering if there's a built-in function for it so I don't hit the database again for something that's already been looked up?)
I'm customizing Details.aspx so that it shows some child records in addition to the fields on the current record. (It's a response to a survey - I'm adding the list of questions with the answer for each question.)
I tried something like this but I got an error, Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
<div></div>Thank you in advance :)
All-Star
17916 Points
5681 Posts
MVP
Re: How to access the data item of the current page?
Nov 22, 2010 11:00 AM|sjnaughton|LINK
Hi Tmmycat, you cannot get access to the current value excep in OnDataBound event then you call GetDataItem() method on the page to get the current value.
Dynamic Data 4
Always seeking an elegant solution.
Member
207 Points
139 Posts
Re: How to access the data item of the current page?
Nov 22, 2010 01:18 PM|tmmycat|LINK
Makes sense ... thank you!!