473,602 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview and Formview Integration

Hello:

I have an aspx page with a Formview and a Gridview on it.

I have a dropdownlist control which I want to bind to both the Formview and
the Gridview.

I put the dropdownlist in the <InsertItemTemp lateof the Formview, so it is
binded with no problem.

I also want to use that dropdownlist's SelectedValue as a parameter that
determines the data displayed in my Gridview.

But now, how do I programatically access that dropdownlist SelectedValue
within the Gridview if it is in the Formview's <InsertItemTemp late>?
Oct 30 '06 #1
1 3207
Controls inside a FormView can be accessed using the
FormView.FindCo ntrol method:

DropDownList ddl = (DropDownList) fv.FindControl( "nameofddl" );

Obviously you would want to refine the above by first checking if the
control were returned and if it were of the correct type. Best practice
would be to have the page implement an Interface with a Property to
return the DropDown.

The FormView creates its controls dynamically depending on the Mode and
which template is loaded. FindControl will not return the desired
control until after the FormView's Controls collection has been
populated. The FormView's PreRender method is one place where it is
safe to use FindControl. You might also use Page.LoadComple te.
HTH,
Chris

Oct 30 '06 #2

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

Similar topics

2
3316
by: Dabbler | last post by:
What's the best way to return to GridView after editing a detail record in a FormView so the GridView shows the page with the edited record on it? I'm using GridView with standard ObjectDataSource, no custom paging. Thanks for any tips on this.
1
2695
by: Kyle K. | last post by:
I would like to build my data pages such that the top of the page contains a GridView showing the data with 'Enable Select = true'. Below that I would like to have a FormView, that by default is in 'Insert' mode for creating a new record. If the user 'selects' a record in the GridView above, I would like to set the FormView to 'Edit' mode with the 'selected' record data loaded in it for editing. I would use the built-in editing...
1
5209
by: joechipubik | last post by:
I have a GridView in a FormView that has as its datasource a DataTable that is stored in the session cache. When I first load the page the GridView is displayed correctly, but on subsequent loads the GridView does not display. I've debugged the DataTable and even when it has data and is bound to the GridView, when the page loads the GridView is not displayed. I set the datasource and then bind the GridView. I've tried disabling the...
0
3550
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
0
4741
by: ThePurpleCat | last post by:
Hi, I'm a newbie to ASP.NET programming but not to Visual Studio. I'm having trouble getting my Master-Details page to work. I have a page enabled GridView which is linked to a FormView control through an objectdatasource. The paging on my GridView works fine except that when I change the page the FormView does not update. I tried setting the selectedindex to 0 in the GridView's PageIndexChanged event and manually binding the formview...
2
5621
by: needin4mation | last post by:
In a GridView, take for example a delete button. When I click the delete button in my GridView the GridView row is deleted and the GridView rebinds and refreshes the records to show accurately. Problem: I have a GridView that has a select. This select gives a FormView control the data to open. I set the GridView visible to false. I have only my FormView open. This FormView is used to edit, have other DetailsViews that open etc.
0
1588
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. All works well, for example: 1. Select the first row in GridView; The FormView shows the detail correspond to the first record.
0
2136
by: LiamLiamLiam | last post by:
G'day all. I having a problem with my formview. I'll ty to explain my situation as best as i can. I have a page with a search field at the top which is just a simple asp:textbox. Below that i have a gridview which displays the results of the search. if no search is entered, then the gridview shows all records. Below the gridview i have a formview for inserting and editing the records. when a user clicks on one of the records in the...
5
4671
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a SelectParameters with a SessionParameter in the parameters collection and the object stored in the Session is a reference type, the DataGrid fails to enter Line Editing mode. Is this a bug? Is there a workaround for this problem?
0
7993
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7920
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6730
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5867
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.