DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 23 Jul 2007 11:36:06 -0700,    posted on: microsoft.public.dotnet.framework.adonet        back       

Thread Index
  1    Gerhard am
          2    Brandon Gano
          3    (WenYuan Wang [MSFT])
          4    (WenYuan Wang [MSFT])


GridView databinding   
I have a GridView which is bound to a table.  The user has the ability to 
change some defaults and then run a process from this.

This all worked fine until I added in an auto postback to one of the 
controls to tie in some other functionality.

After the post back, and at the end of page load complete, everything is as 
it should be, but then the GridView does an automatic databind (after load 
complete) and wipes it all out.  Is there anyway to keep this automatic 
update from occuring, or cancel it or whatever?

Thanks.
Date:Mon, 23 Jul 2007 11:36:06 -0700   Author:  

Re: GridView databinding   
You should be able to override the OnDataBinding event for the table. You 
can check for Page.IsPostBack there and cancel the data binding if 
necessary.


"Gerhard" <acsla@community.nospam> wrote in message 
news:1275AD0D-1F8F-403A-ABA6-964A52560B41@microsoft.com...

>I have a GridView which is bound to a table.  The user has the ability to
> change some defaults and then run a process from this.
>
> This all worked fine until I added in an auto postback to one of the
> controls to tie in some other functionality.
>
> After the post back, and at the end of page load complete, everything is 
> as
> it should be, but then the GridView does an automatic databind (after load
> complete) and wipes it all out.  Is there anyway to keep this automatic
> update from occuring, or cancel it or whatever?
>
> Thanks. 
Date:Mon, 23 Jul 2007 14:40:03 -0700   Author:  

RE: GridView databinding   
Dear Acsla,
Thanks for Brandon's response.

Actually, this is a known issue in Asp.net 2.0 Application.
asp.net 2.0 databound controls will automatically do the databinding when 
the DataSourceID is configured...  Also, this automatic databinding is 
performed during the PreRender event

If you want to get rid of automatic databinding, 1) Brandon's idea is a 
good solution.

2) For another choice, I'd like to suggest you use DBDataAdapter/DataSet 
rather than DataSource Control. DataSource Control is a new component in 
ASP.net 2.0. ASP.net 2.0 will retrieve data from DataSource control 
automatically when we assign it to DataGrid.DataSourceID in design mode.

You can fill dataset by DataAdapter and set dataset to DataGrid.DataSource 
property.
Call DataGrid.DataBind() method when necessary.
For example:
SqlConnection cn=new SqlConnection();
SqlCommand scd=new SqlCommand()
SqlDataAdatper sda=new SqlDataAdapter(scd,cn);
DataSet ds=new DataSet();
Sda.Fill(ds);
this.DataGrid1.DataSource=ds;
this.DataGrid1.DataBind();

3) Steven provided two solutions (set DataSourceID in runtime or get the 
IEnumerable collection from DataSouce Contol.) for such issue.
     a. Assign the DataSourceID at runtime (in a certain of your control's 
postback event) and call databind method.... 

     b. Call DataSourceControl.Select method to get the IEnumerable 
collection (datasource object) and assign it to DataBoundControl.DataSource 
property and call databind method.
 
http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
se_thread/thread/b44e282bb0b0f95f/86036d48e0418053?lnk=st&q=ASP+Net+-+2.0+co
ntrolling+Databinding&rnum=3&hl=zh-CN#86036d48e0418053
[2.0 controlling Databinding ]

Hope this helps. Please feel free to let me know if you have anything 
unclear. We are glad to assist you. Have a great day,
Sincerely,
Wen Yuan
Microsoft Online Community Support 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Wed, 25 Jul 2007 09:42:39 GMT   Author:  

RE: GridView databinding   
Dear Acsla,

This is Wen Yuan again. I just want to check if the issue has been resolved 
so far?
If there is anything unclear, please feel free to update here. We are glad 
to assist you.

Have a great day,
Best regards, 
Wen Yuan
Microsoft Online Community Support
 =================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Date:Fri, 27 Jul 2007 11:06:50 GMT   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us