Click here to Skip to main content
15,906,097 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How do I create User Id and Password Pin
Adekolurejo25-Apr-06 6:43
Adekolurejo25-Apr-06 6:43 
QuestionSetting DataSets/DataViews to null or .Dispose Pin
ikorenbl25-Apr-06 3:43
ikorenbl25-Apr-06 3:43 
AnswerRe: Setting DataSets/DataViews to null or .Dispose Pin
minhpc_bk25-Apr-06 16:27
minhpc_bk25-Apr-06 16:27 
QuestionAsp.ent application Process w3wp does not ends.. Pin
abhinish25-Apr-06 3:40
abhinish25-Apr-06 3:40 
AnswerRe: Asp.ent application Process w3wp does not ends.. Pin
Richard Parsons25-Apr-06 3:57
Richard Parsons25-Apr-06 3:57 
Questionproblem in putting webdatechooser infragistics control inside update panel Pin
R.K.MuthuKumarasamy25-Apr-06 3:22
R.K.MuthuKumarasamy25-Apr-06 3:22 
AnswerRe: problem in putting webdatechooser infragistics control inside update panel Pin
Richard Parsons25-Apr-06 4:02
Richard Parsons25-Apr-06 4:02 
QuestionDynamic control creation and page lifecycle Pin
J4amieC25-Apr-06 2:53
J4amieC25-Apr-06 2:53 
Hi All,

This is a bit of a complex one, appologies in advance if this post ends up being long.

I am creating a dynamic questionnaire system, which is data driven, is split across pages and has 4 different types of question (SingleSelect, MultiSelect, SingleLineTex, MultiLinetext) each created as a UserControl. Each page of the questionnaire can have multiple groups of questions (called a QuestionGroup), and each question group can have multiple Questions.

The problem im facing, in brief, is that when the page is posted back the data for the questions within a group is no longer available. Im tearing my hair out with this, as winforms dev is my normal thing and not knowing how to do something in web development is mighty frustrating!!

Ill try to be more detailed. I have a web user control called QuestionGroupControl, roughly defined as follows:

<%@ Control Language="c#" AutoEventWireup="false" Codebehind="QuestionGroupControl.ascx.cs" 
Inherits="BroadSystem.QuestionnaireWeb.Controls.QuestionGroupControl" 
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<asp:Table Runat="server" ID="QuestionGroupTable" CssClass="questionGroup" CellPadding="0"
	CellSpacing="0">
	<asp:TableRow>
		<asp:TableHeaderCell CssClass="questionGroupHeader">
			<%# QuestionGroup.Text %>
		</asp:TableHeaderCell>
	</asp:TableRow>
	<asp:TableRow HorizontalAlign="Left">
		<asp:TableCell CssClass="questionGroupBody">
			<asp:Panel id="QuestionGroupPanel" runat="server"></asp:Panel>
		</asp:TableCell>
	</asp:TableRow>
</asp:Table>


QuestionGroupPanel is where I dynamically populate each question within that group (this can be one of 4 controls as defined above). Here is the code im using in the code behind of the QuestionGroupControl:

protected override void OnLoad(EventArgs e)
{
	foreach(QuestionnaireDataset.QuestionRow question in this.QuestionGroup.GetQuestionRows())
	{
		string control = question.QuestionTypeControl;
		QuestionnaireBaseUserControl ctrl = (QuestionnaireBaseUserControl)LoadControl(control);
		ctrl.Question = question;
		this.QuestionGroupPanel.Controls.Add(ctrl);
	}
	base.OnLoad (e);
}


And for clarity this.QuestionGroup is defined as follows:

public QuestionnaireDataset.QuestionGroupRow QuestionGroup
{
	get
	{
		return questionGroup; 
	}
	set
	{
		questionGroup = value;	
	}
}


You can see im using a typed dataset, and within my aspx page this is the relevant section.

<asp:Repeater id=Content Runat="server">
	<ItemTemplate>
		<BS:QuestionGroup ID="QuestionGroup" runat="Server" QuestionGroup='<%#Container.DataItem%>' />
	</ItemTemplate>
</asp:Repeater


I, of course, assign my QuestionGroup datatable as the datasource for the repeater on the page.

The error I get is within the OnLoad override in the QuestionGroupControl - it says (quite rightly) that on this line:
foreach(QuestionnaireDataset.QuestionRow question in this.QuestionGroup.GetQuestionRows())
that this.QuestionGroup is null.

Im 99% sure its the order in which im building the controls up, has anyone got ANY pointers for me?


Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour


-- modified at 9:38 Tuesday 25th April, 2006
AnswerRe: Dynamic control creation &amp;amp;amp; page lifecycle Pin
Paddy Boyd25-Apr-06 3:09
Paddy Boyd25-Apr-06 3:09 
GeneralRe: Dynamic control creation &amp;amp;amp;amp; page lifecycle Pin
J4amieC25-Apr-06 3:22
J4amieC25-Apr-06 3:22 
GeneralRe: Dynamic control creation &amp;amp;amp;amp; page lifecycle Pin
Paddy Boyd25-Apr-06 3:30
Paddy Boyd25-Apr-06 3:30 
AnswerRe: Dynamic control creation and page lifecycle Pin
minhpc_bk25-Apr-06 15:21
minhpc_bk25-Apr-06 15:21 
GeneralRe: Dynamic control creation and page lifecycle Pin
J4amieC25-Apr-06 22:02
J4amieC25-Apr-06 22:02 
QuestionGetting Specific Record In XML Pin
naveedmazhar25-Apr-06 2:08
naveedmazhar25-Apr-06 2:08 
AnswerRe: Getting Specific Record In XML Pin
Paddy Boyd25-Apr-06 2:52
Paddy Boyd25-Apr-06 2:52 
AnswerRe: Getting Specific Record In XML Pin
Richard Parsons25-Apr-06 4:04
Richard Parsons25-Apr-06 4:04 
QuestionModify postback client side? Pin
FruitBatInShades25-Apr-06 1:33
FruitBatInShades25-Apr-06 1:33 
GeneralRe: Modify postback client side? Pin
Richard Parsons25-Apr-06 4:11
Richard Parsons25-Apr-06 4:11 
GeneralRe: Modify postback client side? Pin
NeverHeardOfMe25-Apr-06 6:23
NeverHeardOfMe25-Apr-06 6:23 
GeneralRe: Modify postback client side? Pin
NeverHeardOfMe25-Apr-06 11:34
NeverHeardOfMe25-Apr-06 11:34 
Questionquestionaire Pin
D.N.25-Apr-06 1:23
D.N.25-Apr-06 1:23 
AnswerRe: questionaire Pin
Colin Angus Mackay25-Apr-06 2:23
Colin Angus Mackay25-Apr-06 2:23 
AnswerRe: questionaire Pin
Richard Parsons25-Apr-06 4:13
Richard Parsons25-Apr-06 4:13 
QuestionTextbox Find Pin
kirthikirthi25-Apr-06 1:14
kirthikirthi25-Apr-06 1:14 
AnswerRe: Textbox Find Pin
CWIZO25-Apr-06 2:34
CWIZO25-Apr-06 2:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.