specify row to edit when opening formview from gridview?

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.
 
G

Guest

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top