FormView edit/update question
"Clark, Michael (OFM)" <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.web |
|---|---|
| Message-ID | <[email protected]> |
I have been unable to figure out how to bind a DropDownList (actually I
have five to do this with) into a FormViewControl in Edit mode so that
when the user clicks the Update button it picks up the selected item and
passes it to the update method as a parameter. Seems like it should be
simple, but it's eluding me.
Here's some code showing what I have come up with so far -- it gets me
partway there, but no farther.
In the .aspx:
<asp:DropDownList ID="ReviewApproveDropDownList" runat="server">
</asp:DropDownList>
I couldn't see a way to bind the selected item to the object data
source, so I thought I could accomplish it in the DataBound event
handler.
The code I put in the ProfileFormView_DataBound event handler:
DropDownList reviewApproveList =
(DropDownList)ProfileFormView.FindControl("ReviewApproveDropDownList");
ListItem reviewerApprover = new
ListItem(item.ApproverDelegateFullNameLNF,
item.ApproverDelegate.ToString());
reviewApproveList.Items.Add(reviewerApprover);
reviewApproveList.DataSourceID = "ProfileDataSource";
reviewApproveList.DataTextField = "ApproverFullNameLNF";
reviewApproveList.DataValueField = "ApproverID";
reviewApproveList.DataBind();
IList<Person> rtaList =
Requestor.GetRequestorRouteToApproverList(item.Agency, item.Subagency);
foreach (Person p in rtaList)
{
reviewerApprover = new ListItem(p.FullNameLNF, p.PersonID.ToString());
reviewApproveList.Items.Add(reviewerApprover);
}
What the above gets me is a nice dropdownlist with the current value as
the selected item, and the list of items brought back from the
GetRequestorRouteToApproverList in the drop down list.
HOWEVER, when the FormView's UpdateButton is clicked, the dropdownlist
control's value is not among the set of values sent back throught the
ObjectDataSource as parameters.
Any ideas?
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com