473,387 Members | 3,787 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,387 software developers and data experts.

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 ObjectDataSource and what
is best "pattern" for using ObjectDataSource
As you could see in previous example i am looking for best practice to use
FormView / ObjectDataSource 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 1968

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

Similar topics

3
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...
2
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...
1
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...
0
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...
0
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...
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. ...
2
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
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...
5
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.