473,409 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

specify row to edit when opening formview from gridview?

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.
Mar 22 '06 #1
3 4448
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.

"Dabbler" wrote:
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.

Mar 22 '06 #2

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.

"clickon" wrote:
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.

"Dabbler" wrote:
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.

Mar 23 '06 #3
In your FormView datasource object you can specify a QueryStringParamter that
picks up the value that you passed through the URL
http://msdn2.microsoft.com/en-us/lib...er(VS.80).aspx

For example, you can write:
<SelectParameters>
<asp:QueryStringParameter Name="VanId" QueryStringField="pk" />
</SelectParameters>
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
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.

Mar 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: P. Yanzick | last post by:
Hello, I am creating an edit template for a FormView control, changing one of the textboxes to a dropdown box. The dropdown will be populated from a simple table with the primary key, and a...
7
by: Lorenzino | last post by:
Hi, I have a problem with bindings in a formview. I have a formview; in the insert template i've created a wizard control and inside it i have an HTML table with some textboxes bound to the...
1
by: mosscliffe | last post by:
Is it possible to get a GridView 'Select' to go straight to the 'Edit' of a Formview. If I add a 'New' button to the GridView can I get that to go straight to the Insert of a FormView. Is it...
0
by: tarscher | last post by:
Hi all, I have a gridview containing the edit functionality. When I use the edit function and click update another validator is triggered. That validator is not attached to the gridview since it...
0
by: David | last post by:
I have a GridView with an Edit command. I am setting a flag when the edit starts and turning it off when the row is updated. I want to give the user a warning (I am using onbeforeunload javascript...
0
by: Q. John Chen | last post by:
I have a GridView and a FormView serve as master/detail relation. The GridView has paging enabled - 10 rows/page. The formView is linked to gridView's SelectedValue as the sole parameter. ...
1
by: shapper | last post by:
Hello, In have a web page layout with various panels. One panel contains a GridView and other panel contains various TextBox, DropDownList, etc. When I click a a GridView row I make visible...
1
by: shapper | last post by:
Hello, I have a GridView where each row has an EDIT and a DELETE buttons. I also have a FormView with TextBoxes, DropDownLists, etc. When an EDIT button is pressed I make the...
1
by: mans | last post by:
Hello, I want to enable the edit template in a FormView from program. How can I do this? The FormView bound to a table and I don't want that it do the edit/add/delete but I control when it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.