cartch2008
asked on
Formview inside a repeater control
I want to nest formviews (have them always be in edit mode) in a repeater control. Is this possible? If so, how can I do it?
ie: My repeater will pull all orders a customer has. Inside that repeater, I will get the detail of each order and display it in a formview.
ie: My repeater will pull all orders a customer has. Inside that repeater, I will get the detail of each order and display it in a formview.
ASKER
Thanks NazoUK...I'm quite new to asp.net...I have been developing in classic asp for about 10 years though. There would't be more than 10 records on the page. Any way you can sketch it out a bit for me?
thanks
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is great! Thank you. What if I wanted to reference the txtFirstName control in the databound event of the formview?
Similar principle. Add OnDataBound="fv_DataBound" to the FormView tag and then the code in the snippet
Protected Sub fv_DataBound(ByVal sender As Object, ByVal e As EventArgs)
'sender is the FormView that is being databound
Dim fv As FormView = CType(sender, FormView)
'This seems to get called twice, once with no data (in which case no controls are created) and once with the data.
'We are only interested in the case with data.
If fv.DataItem IsNot Nothing Then
Dim txtFirstName As TextBox = CType(fv.FindControl("txtFirstName"), TextBox)
Dim txtLastName As TextBox = CType(fv.FindControl("txtLastName"), TextBox)
'These textbox variables now point to the 2 textboxes in the Formview
End If
End Sub
ASKER
This was the best response I have ever received from anyone on experts exhange. NazoUK has gone above and beyond expectations. I can't think him/her enough.
Thanks for the kind comments. I appreciate it :-)
Probably the easiest way to do it would be to have your formview hooked up to a data source control such as sqldatasource or objectdatasource (depending on where you're getting the data from), which is also in the ItemTemplate of the Repeater. Have a select parameter that corresponds to the primary key of the record in the formview.
Then you'd need to handle the ItemDataBound event of the Repeater to set the parameter of this datasource for each row.
You'd also need to handle the formview events to stop it going into readonly mode after they've updated a record.
This probably sounds a bit vague but I could try to flesh it out a bit for you if you need it.