473,748 Members | 7,827 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FormView and GridView with DataSources

Hello,
I read some msdn and other articles about how does databinding among
DataSource controls and FormView / GridView controls works but I still don't
fully understand to this blackbox. I have few questions and hopefully you can
provide me some answers.

1. Best place for DataBinding.
Where is the best place for calling DataBind method? Is it possible to say
don't bind controls for this postback and use current values instead? These
questions are mainly oriented on non-submit postbacks (like dependency
between two controls in formview, after selecting value in first one, second
one is updated so postback is needed) and for server side validations. I had
some problems with calling validations, populating and binding in proper
order.

Small description of two problems I recently had:
FormView with many controls and validators - after save button is pushed
postback is processed. First in click event handler Page.IsValid is tested.
If page is invalid processing is completed and page has to return to user.
Before this Page_PreRender with FormView's DataBind is called. After this
call all validators become invisible. If I do not call FormView's DataBind,
binding is called automaticly when page is about to render. Only way how to
pass this problem was to validate page again after FormView's DataBind is
called.

Second problem is probably very similar. I had FormView with other
populating postbacks. When populating postback or validation was called
during UpdateMode of FormView, all controls in FormView have been bound to
values from SelectMethod so all changes have been lost. To solve this problem
I put my bussiness object to session and updated datasource to use this
object. In every populating postback object in session was updated by new set
of values. This partial updates caused difficulties because validators for
controls had to be called manually to store every valid value.

2. Best place for storing business object used by ObjectDataSourc e and what
is best "pattern" for using ObjectDataSourc e
As you could see in previous example i am looking for best practice to use
FormView / ObjectDataSourc e controls. My first idea was to use SelectMethod
from session and Update, Delete, Insert method directly to DB. This looks
like odd sloution because previous examples do not work as I would like. So
how to used it in best way?

3. Inserting
This was special problem with FormView. I used InsertMode to create new
item. Is there any possibility how to store values between postbacks? My
soloution with object in Session used for UpdateMode didn't work for
InsertMode. SelectMethod didn't bind controls so after every postback all
controls (textboxes) were blank. My workaround was to store values from
controls to fields and populate them again after FormView's DataBind was
called in Page_PreRender. I realy don't like this solution but i don't have
any idea how to do it better.

I had some similar problems with GridView when i tryed to allow user to make
all changes like inserting, deleting and updating rows and save all changes
to DB after save button has been pushed.

Thanks for any responce / ideas,
Ladislav Mrnka
Feb 1 '07 #1
0 1991

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

Similar topics

3
6043
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is "LabLocation_ID". With an existing lab, they then need to add the members for that lab. So, what I am trying to do is the following. With the FormView of the Lab open, the user will click a button to open a FormView (InsertMode) and add a new...
2
3322
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
3885
by: scartin | last post by:
I'm fairly new to working with ASP web controls, and am running into what seems to be a ridiculous problem that I'm hoping will be a breeze for an experienced ASP developer. I have a GridView and a FormView on the same page, where the GridView is visible at page load, and the FormView is set to Edit mode by default, but is hidden on the page. I have the Select link enabled on my GridView, and I use the SelectedIndexChanged event to hide...
0
3579
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
4746
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...
0
1595
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.
2
2385
by: sck10 | last post by:
Hello, I have 3 objects: LinkButton GridView FormView The LinkButton is used to open the FormView in Insert mode. The GridView provides a list of products. When the "Select" link is
0
2139
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
4681
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
8826
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,...
0
9534
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
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
9241
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
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
6073
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();...
1
3303
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
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.