how to get the data from a repeaterItem

Hi. I have an aspx page that has a repeater and each item in the repeater is an userControl. the user control has 2 dropdown box and an edit box.

Now it is displaying correctly, the user makes a selection in the dropdown types some text in the edit box then he hits the save buton located in the form.

How shall I get the values of the comboboxes and text boxes from the repeater control to save them in the data base?

I tried to loop thru the repater control items. Each repeater item (each row) has 3 controls which I assume are my 2 dropdown boxes and the edit box, but if I use RepeaterItem.Controls.Item(i) and try to cast them to DropDowList or EditBox respectivly the code bombs out.

How do I get the date out?

Do I have to add a method on the control itself to find the dropdownboxes by the name and have the value returned or how do you do it?

I also tried to AddHandler for the dropdown SlectedItemChanged in the user control. It gets called, it tells me the value but I don't have in the control the obeject that needs to be update so the value it's no use since I don't have the item it is suppose to update.

How do you guys usually do it? Thanks a lot.

Adri
[1258 byte] By [apopescu] at [2007-11-20 9:18:19]
# 1 Re: how to get the data from a repeaterItem
I now realize that I was trying to convert the items of the header repeatertem and therefore it was bombing out. I should have checked if the type was ItemType or something.

But I found this on msdn which is sort of what I need. It is not very clear if I should cast all the controls to DataBoundLiteralControl or I should cast to dropdown and combobox? What is a DataBoundLiteralControl and when should it be used?
The whole article on msdn is here : thnks in advance.

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.repeateritem.aspx

Sub Button_Click(Sender As Object, e As EventArgs)
Label1.Text = "The Items collection contains: <br />"

Dim item As RepeaterItem
For Each item In Repeater1.Items
Label1.Text &= _
CType(item.Controls(1), DataBoundLiteralControl).Text & "<br />"
Next item
End Sub
apopescu at 2007-11-10 3:09:05 >