For control the fill like in vs 2003/ asp.net 1.1, another option is add
all the code (generated in vs 2003) in our own custom function, but do not
use the design-time interface since VS 2005 is not targeting the vs 2003
component based data access model. We need to maintain those code ourself.
At runtime, we create the DataSet and Adpater and fill the dataset to bind
to GridView or DataList....
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "GaryDean" <Ga******@newsg roups.nospam>
| References: <e8************ **@TK2MSFTNGP14 .phx.gbl>
<VE************ **@TK2MSFTNGXA0 2.phx.gbl>
<#K************ *@TK2MSFTNGP10. phx.gbl>
<I8************ **@TK2MSFTNGXA0 2.phx.gbl>
<Ow************ **@TK2MSFTNGP15 .phx.gbl>
<lw************ **@TK2MSFTNGXA0 2.phx.gbl>
| Subject: Re: 2.0 controlling Databinding
| Date: Tue, 10 Jan 2006 17:03:27 -0800
| Lines: 380
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <ea************ **@tk2msftngp13 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: user-3cf8219.dsl.min dspring.com 216.244.8.41
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!tk 2msftngp13.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3699 55
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Steven,
| I actually was decoupling the DataSet from the ObjectDataSourc e where it
| destroyed all the columns. You are right, that I can opt to keep the
| columns when decoupling the Gridview from the ObjectDatasourc e.
|
| I still wish we could control the fill like we can in asp 2003 and Forms
| 2005 :)
|
| Thanks for clearing this up.
| --
| Regards,
| Gary Blakely
| "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| news:lw******** ******@TK2MSFTN GXA02.phx.gbl.. .
| > Hi Gary,
| >
| > When you detach a DataSource control from Gridview, you can choose not
to
| > clear the schema so that those defined columns still there and we can
| > choose to assign the datasource control to completely at runtime....
| >
| > And for the new DataSource model, which no longer use vs 2003's data
| > component +DataGrid(which rely on designer genrated code) is also going
to
| > resolve many problem which exists in vs 2003 since those designer
| > generated
| > code is easy to be auto modifed and not easy to control....
| >
| > For SqlDataSource, it's a very simple one which is suitable for RAD or
| > create application prototype. As far as I known most advanced developers
| > will create their own data access components and used with object
| > datasource or still use programmaticall y databinding through code. We're
| > not forced to use any of them...
| >
| > In addition, we're still open to VS 2003 + ASP.NET 1.1 since asp.net
2.0
| > is
| > targeting .net framework 2.0 and new compilation model... If you do feel
| > the old asp.net 1.1 model is more suitable for developing, we can just
use
| > vs 2003 to dev our application in 1.1 version and IIS server can support
| > both version deployed side by side...
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure!
www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| > --------------------
| > | From: "GaryDean" <Ga******@newsg roups.nospam>
| > | References: <e8************ **@TK2MSFTNGP14 .phx.gbl>
| > <VE************ **@TK2MSFTNGXA0 2.phx.gbl>
| > <#K************ *@TK2MSFTNGP10. phx.gbl>
| > <I8************ **@TK2MSFTNGXA0 2.phx.gbl>
| > | Subject: Re: 2.0 controlling Databinding
| > | Date: Mon, 9 Jan 2006 10:35:23 -0800
| > | Lines: 268
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | X-RFC2646: Format=Flowed; Original
| > | Message-ID: <Ow************ **@TK2MSFTNGP15 .phx.gbl>
| > | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| > | NNTP-Posting-Host: 216.244.8.41
| > | Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| > | Xref: TK2MSFTNGXA02.p hx.gbl
| > microsoft.publi c.dotnet.framew ork.aspnet:3695 65
| > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| > |
| > | Steven,
| > | What you say works ok but it does not provide the control we had with
| > the
| > | old dataGrid and Dataset...
| > |
| > | With the datagrid I could add and edit columns at design time from a
| > dataset
| > | (maybe just a template dataset). I could apply edits to dates i.e.
| > {0:d},
| > | provide custom headings, etc. The dataset remained assigned but no
| > fill
| > | was done.
| > |
| > | At run time I could do the fill on a button click event and my grid
| > would
| > | appear with all custom headings and edits in place. However in 2.0
if I
| > do
| > | all of those custom headings and edits at design time and then remove
| > the
| > | datasourceID I get a dialog box that says all columns will be removed
| > and
| > | therefore all of my edits and headings.
| > |
| > | Being able to control the .fill in 1.1 gave us control at a lower
level
| > of
| > | granularity than we have now. BTW, I see that I can control the fill
in
| > | Forms apps still in 2.0 as the .fills are done in the form1.vb file
and
| > I
| > | can move those anywhere I want.
| > |
| > | Is there anyway to control the timing of just the fill in asp?
| > |
| > |
| > | --
| > | Regards,
| > | Gary Blakely
| > | "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| > | news:I8******** ******@TK2MSFTN GXA02.phx.gbl.. .
| > | > Hi Gary,
| > | >
| > | > DataBound control automatically retrieve datas from the DataSource
| > control
| > | > is because you assign the DataSourceID of the databound control at
| > | > design-time, and the 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 do not want such automatic databinding, you can consider
either
| > of
| > | > the following means:
| > | >
| > | > 1. Assign the DataSourceID at runtime (in a certain of your
control's
| > | > postback event) and call databind method....
| > | >
| > | > 2. Call DataSourceContr ol.Select method to get the IEnumerable
| > collection
| > | > (datasource object) and assign it to DataBoundContro l.DataSource
| > property
| > | > and call databind method....
| > | >
| > | > Here is a simple test page which have three buttons, two of them
use
| > the
| > | > above two means and another used for clear the databinding:
| > | >
| > | > =============== =============
| > | > <html xmlns="http://www.w3.org/1999/xhtml" >
| > | > <head runat="server">
| > | > <title>Untitl ed Page</title>
| > | > </head>
| > | > <body>
| > | > <form id="form1" runat="server">
| > | > <div>
| > | > <asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
| > | > ConnectionStrin g="<%$ ConnectionStrin gs:LocalNorthWi nd %>"
| > | > SelectCommand=" SELECT [CategoryID], [CategoryName],
| > | > [Description] FROM [Categories]">
| > | > </asp:SqlDataSour ce>
| > | > <asp:Button ID="btnDetach" runat="server"
| > OnClick="btnDet ach_Click"
| > | > Text="Detach" />
| > | > <asp:Button ID="btnBindDS" runat="server"
| > OnClick="btnBin dDS_Click"
| > | > Text="Bind DataSource Object" />
| > | > <asp:Button ID="btnBindDSC " runat="server"
| > | > OnClick="btnBin dDSC_Click" Text="BindDataS ourceControl" />
| > | > <asp:GridView ID="GridView1" runat="server">
| > | > </asp:GridView>
| > | >
| > | > </div>
| > | > </form>
| > | > </body>
| > | >
| > | >
| > | > =============== =============== ===============
| > | > public partial class GridView_GridVi ewPage : System.Web.UI.P age
| > | > {
| > | > protected void Page_Load(objec t sender, EventArgs e)
| > | > {
| > | >
| > | > }
| > | > protected void btnDetach_Click (object sender, EventArgs e)
| > | > {
| > | > GridView1.DataS ourceID = string.Empty;
| > | > GridView1.DataS ource = null;
| > | > GridView1.DataB ind();
| > | > }
| > | > protected void btnBindDS_Click (object sender, EventArgs e)
| > | > {
| > | > GridView1.DataS ourceID = string.Empty;
| > | > GridView1.DataS ource =
| > | > SqlDataSource1. Select(DataSour ceSelectArgumen ts.Empty);
| > | >
| > | > GridView1.DataB ind();
| > | > }
| > | > protected void btnBindDSC_Clic k(object sender, EventArgs e)
| > | > {
| > | > GridView1.DataS ource = null;
| > | > GridView1.DataS ourceID = "SqlDataSource1 ";
| > | > GridView1.DataB ind();
| > | > }
| > | > }
| > | > =============== ===========
| > | >
| > | > So ASP.NET 2.0 provide both ondemand or automatic (declarative
means)
| > | > databinding... And usually the IDE design-time will help do most of
| > the
| > | > work, however when we need advanced functions or more flexible
design,
| > we
| > | > can still add our code to do it whatever means we like....
| > | >
| > | > Hope helps. Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure!
www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | > --------------------
| > | > | From: "GaryDean" <Ga******@newsg roups.nospam>
| > | > | References: <e8************ **@TK2MSFTNGP14 .phx.gbl>
| > | > <VE************ **@TK2MSFTNGXA0 2.phx.gbl>
| > | > | Subject: Re: 2.0 controlling Databinding
| > | > | Date: Tue, 3 Jan 2006 10:02:58 -0800
| > | > | Lines: 114
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | > | X-RFC2646: Format=Flowed; Original
| > | > | Message-ID: <#K************ *@TK2MSFTNGP10. phx.gbl>
| > | > | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| > | > | NNTP-Posting-Host: user-vcauk40.dsl.min dspring.com 216.175.80.128
| > | > | Path:
| > TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP10.phx. gbl
| > | > | Xref: TK2MSFTNGXA02.p hx.gbl
| > | > microsoft.publi c.dotnet.framew ork.aspnet:3683 22
| > | > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| > | > |
| > | > | let me be more specific.....
| > | > |
| > | > | If I drop a GridView on an aspx page and then create a datasource
| > for
| > it
| > | > and
| > | > | then run the page, it will bind automatically.
| > | > |
| > | > | I DON'T WANT IT TO BIND AUTOMATICALLY. I want it to bind when
| > button1
| > | > is
| > | > | pushed and not until.
| > | > |
| > | > | How can I do that? In other words, how can I control my binding
| > | > | automatically?
| > | > |
| > | > | Thanks,
| > | > | Gary
| > | > |
| > | > | "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in
message
| > | > | news:VE******** ********@TK2MSF TNGXA02.phx.gbl ...
| > | > | > Hi Gary,
| > | > | >
| > | > | > Welcome.
| > | > | > I've also seen your another thread in this group
| > | > | >
| > | > | > Subject: 2.0 DataSources vs. TableAdapter/Datasets
| > | > | >
| > | > | > and posted my response there. As I've mentioned there. In
ASP.NET
| > | > | > application the page instances are not persisted in memory, each
| > time
| > | > a
| > | > | > request has been processed (finished..), the page instance and
| > other
| > | > | > related resources will be disposed... So maintain a member
dataset
| > or
| > | > | > tableadpater is not quite usable as in winform form class....
If
| > you
| > | > do
| > | > | > need global object, you can create and store them in
| > ApplciationStat e
| > | > /
| > | > | > Cache (or session if user specific...), and then we can
reference
| > | > them
| > | > in
| > | > | > other pages' code....
| > | > | >
| > | > | > We can surely perform the same operation on those DataSet and
| > | > | > TableAdapters
| > | > | > like in winform app. e.g:
| > | > | >
| > | > | > taOD = Application("ta _order_details" )
| > | > | > dsOD = Application("ds _order_details" )
| > | > | >
| > | > | > taOD.Fill(dsOD. Order_Details)
| > | > | >
| > | > | > .............
| > | > | >
| > | > | > Thanks,
| > | > | >
| > | > | > Steven Cheng
| > | > | > Microsoft Online Support
| > | > | >
| > | > | > Get Secure!
www.microsoft.com/security
| > | > | > (This posting is provided "AS IS", with no warranties, and
confers
| > no
| > | > | > rights.)
| > | > | >
| > | > | >
| > | > | >
| > | > | > --------------------
| > | > | > | From: "GaryDean" <Ga******@newsg roups.nospam>
| > | > | > | Subject: 2.0 controlling Databinding
| > | > | > | Date: Sat, 31 Dec 2005 14:23:37 -0800
| > | > | > | Lines: 33
| > | > | > | X-Priority: 3
| > | > | > | X-MSMail-Priority: Normal
| > | > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | > | > | X-RFC2646: Format=Flowed; Original
| > | > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | > | > | Message-ID: <e8************ **@TK2MSFTNGP14 .phx.gbl>
| > | > | > | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| > | > | > | NNTP-Posting-Host: user-vcaur7q.dsl.min dspring.com
| > 216.175.108.250
| > | > | > | Path:
| > | > TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| > | > | > | Xref: TK2MSFTNGXA02.p hx.gbl
| > | > | > microsoft.publi c.dotnet.framew ork.aspnet:3678 81
| > | > | > | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| > | > | > |
| > | > | > | We have been noticing that questions on vs.2005/2.0 don't
appear
| > to
| > | > get
| > | > | > much
| > | > | > | in answers so I'm reposting some questions posted by some of
the
| > | > | > programmers
| > | > | > | here in our organization that never got answered...
| > | > | > |
| > | > | > | In 1.1 we always did our own myDataAdapter.f ills and we liked
| > that
| > | > | > control
| > | > | > | for lots of good reasons. Now the new DataSource (or is it a
| > | > | > | TableAdapter:Da taset) automatically fills the Gridview. How
can
| > we
| > | > | > control
| > | > | > | that fill?
| > | > | > |
| > | > | > | In a forms app there is a Form1.vb that has.....
| > | > | > | Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e
As
| > | > | > | System.EventArg s) Handles MyBase.Load
| > | > | > |
| > | > | > | 'TODO: This line of code loads data into the
| > | > | > | 'NorthwindDataS et.Order_Detail s' table. You can move, or
remove
| > it,
| > | > as
| > | > | > | needed.
| > | > | > |
| > | > | > |
| > Me.Order_Detail sTableAdapter.F ill(Me.Northwin dDataSet.Order_ Details)
| > | > | > |
| > | > | > | 'TODO: This line of code loads data into the
| > | > 'NorthwindDataS et.Orders'
| > | > | > | table. You can move, or remove it, as needed.
| > | > | > |
| > | > | > | Me.OrdersTableA dapter1.Fill(Me .NorthwindDataS et.Orders)
| > | > | > |
| > | > | > | End Sub
| > | > | > |
| > | > | > | Here we can remove or place the code where we want but we
can't
| > find
| > | > | > that
| > | > | > | opportunity in asp apps.
| > | > | > | --
| > | > | > | Regards,
| > | > | > | Gary Blakely
| > | > | > |
| > | > | > |
| > | > | > |
| > | > | >
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|