Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two Way DataBinding to DropDownList

Status
Not open for further replies.

raphael232

Programmer
Jun 9, 2006
51
0
0
GB
Hi i'm playing around with the formview control to call my insert method of my business object. I notice that you put <asp:TextBox ID="txtTitle" Text='<%# Bind("Title") %>' runat="server"></asp:TextBox> to get the Title from a TextBox control but what do i bind to other controls such as RadioButtonList and DropDownList so that the values returned can be used in my insert method.

Appreciate the help. Thanks
 
Hi i found a solution to the above problem by using the SelectedValue property but now when i run my page i get:

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

Here the code:

Code:
<asp:DropDownList ID="lstCategoryID" SelectedValue='<%# Bind("CategoryID") %>' runat="server" DataTextField="Text" DataValueField="Value">
                        </asp:DropDownList>

and in my page load event handler:

Code:
Dim lstCategoryID As DropDownList = CType(FormView1.FindControl("lstCategoryID"), DropDownList)
lstCategoryID.DataSource = Utilities.GetCategoriesList(sectionID, 0, "")
lstCategoryID.DataBind()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top