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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top