views:

38

answers:

3

I am trying to get a drop down and a form view to work together. I've never used form views before. I also am using the entity framework to do everything. This is also my first time with it.

I want to be able to have a drop down, that is populate from the same data source as the form view. So far that works fine.

I then want to be able to change the drop down item, and it change the form view item that is displayed. I cannot figure out how to make this work.

A: 

If you set the

<asp:DropDownList AutoPostBack="True" OnSelectedIndexChanged="ddlType_SelectedIndexChanged"  ... />

Then you can have an event handler in the code behind rebind the DataSource for your Form View.

ddlType_SelectedIndexChanged(object sender, EventArgs e)
{
    // rebind your Form View from here.
}
rockinthesixstring
A: 

You can handle the SelectedIndexChanged of the dropdown. Then you can access the element inside the form view as:

(Label)fvCourseInstance.FindControl("lblDropDownValue").Text = ddlYourDropDown.SelectedValue
Teddy
A: 

I found an answer that will work. On the entity framework data source I included a where parameter that is a control that points to the drop down. So when I change the drop down I have an event handler that puts the form view in either insert mode if nothing was selected or read only mode if I selected something. I don't know if this is the best way, but it is working ok for now. Later I'll try and learn more about using form views to see how other people use them.

Anonymous Coward