DetailsView Data Binding

Discussion in 'ASP .Net' started by Andrew Robinson, Sep 30, 2005.

  1. Is there any way to accomplish two way data binding in a Details View with a
    DataSet or DataTable as the DataSource.

    All I want is to get an updated DataSet or DataTable back from the
    DetailsView and then handle my updating manually.

    -Andrew
     
    Andrew Robinson, Sep 30, 2005
    #1
    1. Advertising

  2. Hi Andrew,

    Welcome to ASPNET newsgroup.
    As for the template databound controls such as GridView/DetailsView, and
    the original DataGrid and DAtaList ...., the DataSource instance (DataSet,
    DataTable ...) only exist when the datacontrol is performing databinding.
    After that, the datasource instance no longer exist in the sequential
    request, the datas are persisted in the control through ViewState. So we
    can not directly obtain the original DataSet/DataTable back from The
    databound control on the page. If you're wantting to retrieve the updated
    values (of the controls) in each row and do manual data updating, we have
    the following options:

    1. We still use the DetailsView control's buildin updating mechanism, but
    use the ItemUpdating event to proprocess the update operation. The
    ItemUpdating event, we can get the paramters that will be used to do the
    updating operation and then use them to perform our own update operation.
    And we can use the
    DetailsViewUpdateEventArgs.Cancel to cancel the buildin update operation.

    2. If we don't want the utilize the buildin events, we can use the
    DetailsView.Rows and DetailsViewRow.Cells collection to manually retrieve
    the values from the Bounded control's Text Property. Like:

    protected void Button1_Click(object sender, EventArgs e)
    {
    Response.Write("<br>DetailsView1.Rows.Count: " + DetailsView1.Rows.Count);

    foreach (DetailsViewRow dvr in DetailsView1.Rows)
    {
    Response.Write("<br>dvr.Cells.Count: " + dvr.Cells[1].Text);
    }
    }

    However, all the above options can only retrieve the values for the
    currently active (displayed ) record. Unlike the DataGrid, GridView,
    DetailsView dosn't provide the direct interfaces for loop through all the
    records's data.

    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: "Andrew Robinson" <>
    | Subject: DetailsView Data Binding
    | Date: Fri, 30 Sep 2005 13:44:03 -0700
    | Lines: 9
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
    | X-RFC2646: Format=Flowed; Original
    | Message-ID: <#th3z#>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: 216.57.203.121
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet:128339
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | Is there any way to accomplish two way data binding in a Details View
    with a
    | DataSet or DataTable as the DataSource.
    |
    | All I want is to get an updated DataSet or DataTable back from the
    | DetailsView and then handle my updating manually.
    |
    | -Andrew
    |
    |
    |
     
    Steven Cheng[MSFT], Oct 3, 2005
    #2
    1. Advertising

  3. Hi Andrew,

    How are you doing on this thread, does the suggestions in my last reply
    helps a littile? If there're anything else we can help, please feel free to
    post here.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    --------------------
    | X-Tomcat-ID: 80680570
    | References: <#th3z#>
    | MIME-Version: 1.0
    | Content-Type: text/plain
    | Content-Transfer-Encoding: 7bit
    | From: (Steven Cheng[MSFT])
    | Organization: Microsoft
    | Date: Mon, 03 Oct 2005 06:04:19 GMT
    | Subject: RE: DetailsView Data Binding
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    | Message-ID: <V2WhQB#>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | Lines: 75
    | Path: TK2MSFTNGXA01.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet:128547
    | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
    |
    | Hi Andrew,
    |
    | Welcome to ASPNET newsgroup.
    | As for the template databound controls such as GridView/DetailsView, and
    | the original DataGrid and DAtaList ...., the DataSource instance
    (DataSet,
    | DataTable ...) only exist when the datacontrol is performing databinding.
    | After that, the datasource instance no longer exist in the sequential
    | request, the datas are persisted in the control through ViewState. So we
    | can not directly obtain the original DataSet/DataTable back from The
    | databound control on the page. If you're wantting to retrieve the updated
    | values (of the controls) in each row and do manual data updating, we have
    | the following options:
    |
    | 1. We still use the DetailsView control's buildin updating mechanism, but
    | use the ItemUpdating event to proprocess the update operation. The
    | ItemUpdating event, we can get the paramters that will be used to do the
    | updating operation and then use them to perform our own update operation.
    | And we can use the
    | DetailsViewUpdateEventArgs.Cancel to cancel the buildin update operation.
    |
    | 2. If we don't want the utilize the buildin events, we can use the
    | DetailsView.Rows and DetailsViewRow.Cells collection to manually retrieve
    | the values from the Bounded control's Text Property. Like:
    |
    | protected void Button1_Click(object sender, EventArgs e)
    | {
    | Response.Write("<br>DetailsView1.Rows.Count: " +
    DetailsView1.Rows.Count);
    |
    | foreach (DetailsViewRow dvr in DetailsView1.Rows)
    | {
    | Response.Write("<br>dvr.Cells.Count: " + dvr.Cells[1].Text);
    | }
    | }
    |
    | However, all the above options can only retrieve the values for the
    | currently active (displayed ) record. Unlike the DataGrid, GridView,
    | DetailsView dosn't provide the direct interfaces for loop through all the
    | records's data.
    |
    | 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: "Andrew Robinson" <>
    | | Subject: DetailsView Data Binding
    | | Date: Fri, 30 Sep 2005 13:44:03 -0700
    | | Lines: 9
    | | X-Priority: 3
    | | X-MSMail-Priority: Normal
    | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
    | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
    | | X-RFC2646: Format=Flowed; Original
    | | Message-ID: <#th3z#>
    | | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | | NNTP-Posting-Host: 216.57.203.121
    | | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
    | | Xref: TK2MSFTNGXA01.phx.gbl
    | microsoft.public.dotnet.framework.aspnet:128339
    | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    | |
    | | Is there any way to accomplish two way data binding in a Details View
    | with a
    | | DataSet or DataTable as the DataSource.
    | |
    | | All I want is to get an updated DataSet or DataTable back from the
    | | DetailsView and then handle my updating manually.
    | |
    | | -Andrew
    | |
    | |
    | |
    |
    |
     
    Steven Cheng[MSFT], Oct 10, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jordan
    Replies:
    2
    Views:
    2,536
    Jordan
    Feb 10, 2004
  2. =?Utf-8?B?Q2VyaV9EYXZpZXM=?=

    Binding a textbox to a detailsview in asp.net 2.0

    =?Utf-8?B?Q2VyaV9EYXZpZXM=?=, Mar 22, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    988
    =?Utf-8?B?Q2VyaV9EYXZpZXM=?=
    Mar 22, 2005
  3. Replies:
    0
    Views:
    485
  4. JcFx
    Replies:
    0
    Views:
    280
  5. Feege
    Replies:
    0
    Views:
    463
    Feege
    Dec 20, 2005
Loading...

Share This Page