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******@newsgroups.nospam>
| References: <e8**************@TK2MSFTNGP14.phx.gbl>
<VE**************@TK2MSFTNGXA02.phx.gbl>
<#K*************@TK2MSFTNGP10.phx.gbl>
<I8**************@TK2MSFTNGXA02.phx.gbl>
<Ow**************@TK2MSFTNGP15.phx.gbl>
<lw**************@TK2MSFTNGXA02.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.public.dotnet.framework.aspnet
| NNTP-Posting-Host: user-3cf8219.dsl.mindspring.com 216.244.8.41
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:369955
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Steven,
| I actually was decoupling the DataSet from the ObjectDataSource where it
| destroyed all the columns. You are right, that I can opt to keep the
| columns when decoupling the Gridview from the ObjectDatasource.
|
| 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**************@TK2MSFTNGXA02.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 programmatically 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******@newsgroups.nospam>
| > | References: <e8**************@TK2MSFTNGP14.phx.gbl>
| > <VE**************@TK2MSFTNGXA02.phx.gbl>
| > <#K*************@TK2MSFTNGP10.phx.gbl>
| > <I8**************@TK2MSFTNGXA02.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.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: 216.244.8.41
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:369565
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.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**************@TK2MSFTNGXA02.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 DataSourceControl.Select method to get the IEnumerable
| > collection
| > | > (datasource object) and assign it to DataBoundControl.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>Untitled Page</title>
| > | > </head>
| > | > <body>
| > | > <form id="form1" runat="server">
| > | > <div>
| > | > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
| > | > ConnectionString="<%$ ConnectionStrings:LocalNorthWind %>"
| > | > SelectCommand="SELECT [CategoryID], [CategoryName],
| > | > [Description] FROM [Categories]">
| > | > </asp:SqlDataSource>
| > | > <asp:Button ID="btnDetach" runat="server"
| > OnClick="btnDetach_Click"
| > | > Text="Detach" />
| > | > <asp:Button ID="btnBindDS" runat="server"
| > OnClick="btnBindDS_Click"
| > | > Text="Bind DataSource Object" />
| > | > <asp:Button ID="btnBindDSC" runat="server"
| > | > OnClick="btnBindDSC_Click" Text="BindDataSourceControl" />
| > | > <asp:GridView ID="GridView1" runat="server">
| > | > </asp:GridView>
| > | >
| > | > </div>
| > | > </form>
| > | > </body>
| > | >
| > | >
| > | > =============================================
| > | > public partial class GridView_GridViewPage : System.Web.UI.Page
| > | > {
| > | > protected void Page_Load(object sender, EventArgs e)
| > | > {
| > | >
| > | > }
| > | > protected void btnDetach_Click(object sender, EventArgs e)
| > | > {
| > | > GridView1.DataSourceID = string.Empty;
| > | > GridView1.DataSource = null;
| > | > GridView1.DataBind();
| > | > }
| > | > protected void btnBindDS_Click(object sender, EventArgs e)
| > | > {
| > | > GridView1.DataSourceID = string.Empty;
| > | > GridView1.DataSource =
| > | > SqlDataSource1.Select(DataSourceSelectArguments.Em pty);
| > | >
| > | > GridView1.DataBind();
| > | > }
| > | > protected void btnBindDSC_Click(object sender, EventArgs e)
| > | > {
| > | > GridView1.DataSource = null;
| > | > GridView1.DataSourceID = "SqlDataSource1";
| > | > GridView1.DataBind();
| > | > }
| > | > }
| > | > ==========================
| > | >
| > | > 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******@newsgroups.nospam>
| > | > | References: <e8**************@TK2MSFTNGP14.phx.gbl>
| > | > <VE**************@TK2MSFTNGXA02.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.public.dotnet.framework.aspnet
| > | > | NNTP-Posting-Host: user-vcauk40.dsl.mindspring.com 216.175.80.128
| > | > | Path:
| > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| > | > | Xref: TK2MSFTNGXA02.phx.gbl
| > | > microsoft.public.dotnet.framework.aspnet:368322
| > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.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****************@TK2MSFTNGXA02.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
| > ApplciationState
| > | > /
| > | > | > 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******@newsgroups.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.public.dotnet.framework.aspnet
| > | > | > | NNTP-Posting-Host: user-vcaur7q.dsl.mindspring.com
| > 216.175.108.250
| > | > | > | Path:
| > | > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
| > | > | > | Xref: TK2MSFTNGXA02.phx.gbl
| > | > | > microsoft.public.dotnet.framework.aspnet:367881
| > | > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.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.fills and we liked
| > that
| > | > | > control
| > | > | > | for lots of good reasons. Now the new DataSource (or is it a
| > | > | > | TableAdapter:Dataset) 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(ByVal sender As System.Object, ByVal e
As
| > | > | > | System.EventArgs) Handles MyBase.Load
| > | > | > |
| > | > | > | 'TODO: This line of code loads data into the
| > | > | > | 'NorthwindDataSet.Order_Details' table. You can move, or
remove
| > it,
| > | > as
| > | > | > | needed.
| > | > | > |
| > | > | > |
| > Me.Order_DetailsTableAdapter.Fill(Me.NorthwindData Set.Order_Details)
| > | > | > |
| > | > | > | 'TODO: This line of code loads data into the
| > | > 'NorthwindDataSet.Orders'
| > | > | > | table. You can move, or remove it, as needed.
| > | > | > |
| > | > | > | Me.OrdersTableAdapter1.Fill(Me.NorthwindDataSet.Or ders)
| > | > | > |
| > | > | > | 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
| > | > | > |
| > | > | > |
| > | > | > |
| > | > | >
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|