Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Strange behavior of RadioButtonList inside a Repeater

Reply
Thread Tools

Strange behavior of RadioButtonList inside a Repeater

 
 
ri_davila@yahoo.com
Guest
Posts: n/a
 
      05-09-2006
I made a Web User Control "QuestionUserControl" that contains a RadioButtonList and a TextBox. On my web form I use that control inside a Repeater.

(i changed the tags so the code is shown)

[ASP:REPEATER id="QuestionRepeater" runat="server"]
[ITEMTEMPLATE]
[UC1:QUESTIONUSERCONTROL id="quc" runat="server"][/UC1:QUESTIONUSERCONTROL]
[/ITEMTEMPLATE]
[/ASP:REPEATER]

The repeater is then bound to a data source that contains records in the following format: QuestionId INT, QuestionType BYTE (1 = choice, 2 = text)

On the Repeater's DataBound event I call a public method of the QuestionUserControl passing the DataRow that contains QuestionId and QuestionType.


private void QuestionRepeater_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
( (Cuestionario.QuestionUserControl)e.Item.FindContr ol("quc") ).ContructQuestion((DataRowView)e.Item.DataItem, this.m_Language);
}


The Public Method in the QuestionUserControl then shows or hides the RadioButtonList or the TextBox depending on the QuestionType. If QuestionType was "choices" the QuestionUserControl then uses QuestionId to retreive a list of choices from the database and binds that to the RadioButtonList.

After the user posts back I gather the values from the multiple QuestionUserControls created by the repeater in the QuestionUserControl_UnLoad event.

Now the problem.

I can gather all the values posted except for the very first RadioButtonList that gets created. Example:

Repeater's Datasource:

The repeater creates 5 QuestionUserControls.

QuestionId QuestionType
1 -------- 1
2 -------- 1
3 -------- 2
4 -------- 1
5 -------- 2

This creates 5 QuestionUserControls.
The QuestionUserControls that receive a QuestionType == 1, retreive a list of choices and binds them to the RadioButtonList and hide the TextBox.
The QuestionUserControls that receive a QuestionType == 2, simply hide the RadioButtonList and shows the TextBox.

When the user submits the form, the QuestionUserControl_UnLoad event gets fired 5 times, one for each QuestionUserControl created by the repeater. Inside each QuestionUserControl_UnLoad event I have access to the RadioButtonList and the TextBox contained on that particular QuestionUserControl created by the repeater, so I can gather the values of each QuestionUserControl separately.

Once again, inside each QuestionUserControl_UnLoad I can get the values w/o a problem except for the very first QuestionUserControl that has a RadioButtonList.

I changed the order of the questions to put a QuestionUserControl that gets QuestionType == 2 (text) at the top and it had no problems. So it really doesn't matter the order of the QuestionUserControls that the Repeater creates.

The very first QuestionUserControl that contains a RadioButtonList acts as if the RadioButtonList has just been initialized with properties like:

SelectedIndex = -1
SelectedValue = ""


Sorry for such a long post. I just wanted to make sure you have all the info to help me. This is really driving me crazy .

TIA
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
repeater inside a repeater problem. uncensored ASP .Net 0 10-25-2006 06:10 PM
Repeater inside a Repeater Microsoft ASP .Net Web Controls 0 08-21-2006 09:13 AM
Handling Radiobuttonlist event inside Repeater Control Ravi ASP .Net 2 08-18-2006 06:56 AM
Repeater inside a repeater....how? voidfill3d@yahoo.com ASP .Net 1 08-10-2005 01:58 PM
RadioButtonList inside Repeater robk ASP .Net Web Controls 0 07-07-2005 05:50 PM



Advertisments