Search code examples
c#asp.netgridviewformview

FormView to populate from selection on GridView


I have a DropDownList that populates a GridView according to the selected value. I then have a FormView that I want to populate with data depending on what field was selected out of the DataGrid.

My GridView has DataKeyNames="ID", and I then use the following to update the selected field:

<ItemTemplate> <a href="#" onclick="addEdit(<%# Eval("ID") %>)">Update</a> </ItemTemplate>

My FormView's ObjectDataSource uses the following:

<asp:ControlParameter ControlID="grvMain" Name="pID" PropertyName="SelectedValue" Type="Int32" />

I still can't seem to get the FormView populated with the correct data, or any data at all for that matter, when user clicks on Update in the grid.

Any ideas?


Solution

  • Add the following, to the gridview

    <asp:CommandField ShowSelectButton="True" />
    

    Should create a select button.