DetailsView updates unused properties to null

Discussion in 'ASP .Net' started by Nick Bennett, Jan 20, 2008.

  1. Nick Bennett

    Nick Bennett Guest

    I've got a page with a DetailsView. It uses a SqlDataSource which itself
    uses stored procedures for Select and Update.

    I don't want the user to see some of the columns, but if I don't bind them
    (or if I do bind them but set Visible=False), when the Update procedure is
    called, the parameters corresponding to the columns that weren't bound to
    the DetailsView are all null.

    This can't be an uncommon scenario, so I guess I have missed something. Any
    ideas?
     
    Nick Bennett, Jan 20, 2008
    #1
    1. Advertising

  2. Howdy,

    Take a look at BoundField's InsertVisible property as well as SqlDataSource
    Updating/Inserting events.

    Regards
    --
    Milosz


    "Nick Bennett" wrote:

    > I've got a page with a DetailsView. It uses a SqlDataSource which itself
    > uses stored procedures for Select and Update.
    >
    > I don't want the user to see some of the columns, but if I don't bind them
    > (or if I do bind them but set Visible=False), when the Update procedure is
    > called, the parameters corresponding to the columns that weren't bound to
    > the DetailsView are all null.
    >
    > This can't be an uncommon scenario, so I guess I have missed something. Any
    > ideas?
    >
    >
    >
     
    Milosz Skalecki [MCAD], Jan 20, 2008
    #2
    1. Advertising

  3. Nick Bennett

    Angel Guest

    Using BoundField might help but keep in mind that things get really ugly when
    you mix Declarative stuff and code. My suggestion to you is go completely
    code replace the sqldatasource with a dataset or datatable and user the
    datasource property instead.

    Where it get tricky is if you have dropdowns or any other template based
    field it can get a little hard to do but is doable I have a demo depicting a
    dynamic situation
    similar to the one you are describing. Mine involves a detailsview and
    Gridview in a master/details relationship. One page hitting multiple table
    and columns are defined at runtime.

    If you are interested let me know and I will be glad to share this with you.
    --
    aaa


    "Nick Bennett" wrote:

    > I've got a page with a DetailsView. It uses a SqlDataSource which itself
    > uses stored procedures for Select and Update.
    >
    > I don't want the user to see some of the columns, but if I don't bind them
    > (or if I do bind them but set Visible=False), when the Update procedure is
    > called, the parameters corresponding to the columns that weren't bound to
    > the DetailsView are all null.
    >
    > This can't be an uncommon scenario, so I guess I have missed something. Any
    > ideas?
    >
    >
    >
     
    Angel, Jan 23, 2008
    #3
  4. Nick Bennett

    Paul Shapiro Guest

    You could use a stored procedure which did not include parameters for the
    columns you don't want updated.

    An asp:Boundfield has a ConvertEmptyStringToNull property. Have you tried
    setting that to false?

    "Nick Bennett" <> wrote in message
    news:...
    > I've got a page with a DetailsView. It uses a SqlDataSource which itself
    > uses stored procedures for Select and Update.
    >
    > I don't want the user to see some of the columns, but if I don't bind them
    > (or if I do bind them but set Visible=False), when the Update procedure is
    > called, the parameters corresponding to the columns that weren't bound to
    > the DetailsView are all null.
    >
    > This can't be an uncommon scenario, so I guess I have missed something.
    > Any ideas?
     
    Paul Shapiro, Feb 11, 2008
    #4
    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. sck10
    Replies:
    3
    Views:
    15,888
    techstuffbc
    Aug 19, 2009
  2. Replies:
    5
    Views:
    27,542
    Mike Schilling
    Mar 29, 2006
  3. K B
    Replies:
    0
    Views:
    559
  4. Feege
    Replies:
    0
    Views:
    502
    Feege
    Dec 20, 2005
  5. Nick Bennett

    DetailsView updates unused properties to null

    Nick Bennett, Jan 20, 2008, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    124
    Paul Shapiro
    Feb 11, 2008
Loading...

Share This Page