specify row to edit when opening formview from gridview?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the best way to have a FormView page open on a specific row selected
from a GridView?

I'm passing the primary key in the url as in
detailview.aspx?mode=edit&pk=42

I'm using an SqlDataSource to bind the FormView to the data.

Thanks for any samples or links.
 
Don't pass the primary key in URL, instead, have your SelectCommand statement
for your SQL datasource that is bound to the formview read something like

"Select PrimaryKey, field1, field2, fields3 from table where
primarykey=@PrimaryKey"

then have a <SelectParameters> section that reads something like this

<SelectParameters>
<asp:ControlParameter ControlID="FormViewID" Name="PrimaryKey"
PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>

Then it will just work.
 
My mistake for being unclear. The Gridview is on one page, selecting the row
is supposed to open another page with a FormView. This table has lots of rows
and columns so I can't put both on one page.

The real gist of the question is, how does one specify what row a FormView
should edit as the page loads?

Thanks.
 
Back
Top