Re: DetailsView Insert

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thank you, Clinton. It may take some time for me to increase my level of
understanding enough to be able to utilize your comments, but I knew that
information must be in there somewhere. I was able to follow Steven's
suggestion by creating a stored procedure for the INSERT. I follow the INSERT
command with a SELECT based upon the IDENT_CURRENT value. This worked well
and allowed me to display the inserted record back to the user in the
DetailsView control.

"clintonG" wrote:

> I've been trying to learn these new controls myself. The autogenerated ID is
> in the control tree hierarchy which can be observed using the Trace page
> directive. The generated ID can literally be passed as an argument in code
> as it is used in the ViewState. Depending where 'your' control is in the
> hierarchy any further addition of controls to the page however can reorder
> the autogenerated hierarchy.
>
>
> <%= Clinton Gallagher
> METROmilwaukee (sm) "A Regional Information Service"
> NET csgallagher AT metromilwaukee.com
> URL http://metromilwaukee.com/
> URL http://clintongallagher.metromilwaukee.com/
>
>
> "Steven Cheng[MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
> news:J96QIFZoFHA.944@xxxxxxxxxxxxxxxxxxxxxxxx
> > Hi Radio,
> >
> > Thanks for your response. En, after some local tests in the beta2
> > enviornment, I think you're right. The .NET SqlDataSource's Inserted event
> > implementation only return the updated parameters which is supplied before
> > executing the command, so for the autogenerated ID(which isn't presupplied
> > ) , it won't be returned back.
> > Currently my opinion for such scenario would be use a custom sqlcommand to
> > execute such insert command separatly, thus we can append a sqlstatement
> > which query the IDENT_CURRENT after executing the insert statement. This
> > would be rather more flexible.
> >
> > Thanks & Regards,
> >
> > Steven Cheng
> > Microsoft Online Support
> >
> > Get Secure! www.microsoft.com/security
> > (This posting is provided "AS IS", with no warranties, and confers no
> > rights.)
> >
> >
> > --------------------
> > | Thread-Topic: DetailsView Insert
> > | thread-index: AcWfX/5P12wGjBZbQC2S9aL/yRX4Rg==
> > | X-WBNR-Posting-Host: 24.74.0.57
> > | From: "=?Utf-8?B?UmFkaW9TaWduYWw=?=" <RadioSignal@xxxxxxxxxxxxxxxx>
> > | References: <C579A829-E93F-41F5-9AC5-E0BB58189D34@xxxxxxxxxxxxx>
> > <oBJ8eUznFHA.2700@xxxxxxxxxxxxxxxxxxxxx>
> > | Subject: RE: DetailsView Insert
> > | Date: Fri, 12 Aug 2005 10:05:08 -0700
> > | Lines: 91
> > | Message-ID: <80983B1A-3FCE-409A-8DA4-BFF348B18315@xxxxxxxxxxxxx>
> > | MIME-Version: 1.0
> > | Content-Type: text/plain;
> > | charset="Utf-8"
> > | Content-Transfer-Encoding: 7bit
> > | X-Newsreader: Microsoft CDO for Windows 2000
> > | Content-Class: urn:content-classes:message
> > | Importance: normal
> > | Priority: normal
> > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
> > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
> > | Xref: TK2MSFTNGXA01.phx.gbl
> > microsoft.public.dotnet.framework.aspnet.webcontrols:10418
> > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
> > |
> > | Thank you Steven.
> > |
> > | Yes, I want to get either the autogenerated key or some other way to
> > echo
> > | the newly inserted DetailsView record back to the user. We shouldn't
> > require
> > | the user to page through a table of records to find the row he just
> > inserted.
> > |
> > | I tried your suggestion of using the SqlDataSource's Inserted event, but
> > I
> > | only received the updated parameters from the parameter list which I
> > supplied
> > | in the DetailsView INSERT request, such as @LastName, @FirstName etc. I
> > do
> > | not receive the desired @NameID key. I also cannot supply the @NameID as
> > a
> > | parameter since this will error the INSERT on an auto generated field.
> > |
> > | I could of course supply a new DetailsView querry based upon other
> > non-key
> > | fields from the Inserted record, but that requires the database to hunt
> > | through who knows how many rows to find something that we should already
> > know
> > | how to retrieve.
> > |
> > | I was considering a re-querry to the database for the last key created
> > on
> > | this table using an IDENT_CURRENT function, but I'm not sure how to do
> > that
> > | in this context.
> > |
> > |
> > | "Steven Cheng[MSFT]" wrote:
> > |
> > | > Hi Radio,
> > | >
> > | > Welcome to MSDN newsgroup.
> > | > From your description, you're using DetailsView to display data and
> > | > inserting data. When you inserting some datas in DetailsView(which has
> > a
> > | > autogenerated column in db), you're wondering how to get the
> > autogenerated
> > | > primary key(identity), yes?
> > | >
> > | > Based on my research, the DetailsView's Inserting event didn't
> > indicate
> > | > that it'll return the updated(autogenerated field)'s value.
> > | > However,according to the current BETA document the SqlDataSource's
> > Inserted
> > | > event seems provide such output value, you can refer to the following
> > | > document:
> > | >
> > | > #SqlDataSourceStatusEventArgs Class (System.Web.UI.WebControls)
> > | > http://msdn2.microsoft.com/library/z452ftck(en-us,vs.80).aspx
> > | >
> > | > Also, for detailsView, you can rebind the the DetaislView from teh
> > | > datasource which will requery the records with the updated one which
> > | > contains the pk field.
> > | >
> > | > 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.)
> > | >
> > | >
> > | >
> > | >
> > | > --------------------
> > | > | Thread-Topic: DetailsView Insert
> > | > | thread-index: AcWeqc/mMR9HQTUKS72+gH5yG65XLQ==
> > | > | X-WBNR-Posting-Host: 192.85.47.2
> > | > | From: "=?Utf-8?B?UmFkaW9TaWduYWw=?=" <RadioSignal@xxxxxxxxxxxxxxxx>
> > | > | Subject: DetailsView Insert
> > | > | Date: Thu, 11 Aug 2005 12:21:02 -0700
> > | > | Lines: 4
> > | > | Message-ID: <C579A829-E93F-41F5-9AC5-E0BB58189D34@xxxxxxxxxxxxx>
> > | > | MIME-Version: 1.0
> > | > | Content-Type: text/plain;
> > | > | charset="Utf-8"
> > | > | Content-Transfer-Encoding: 7bit
> > | > | X-Newsreader: Microsoft CDO for Windows 2000
> > | > | Content-Class: urn:content-classes:message
> > | > | Importance: normal
> > | > | Priority: normal
> > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> > | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
> > | > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> > | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
> > | > | Xref: TK2MSFTNGXA01.phx.gbl
> > | > microsoft.public.dotnet.framework.aspnet.webcontrols:10401
> > | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
> > | > |
> > | > | After a successful DetailsView SQL INSERT of a row with an
> > autogenerated
> > | > | IDENTITY column key, I'd like to re-display the new database record
> > back
> > | > to
> > | > | the user but the key returned in the DetailsView ItemInserted Event
> > args
> > | > is
> > | > | NULL. How do I obtain the new key for the confirmation SELECT?
> > | > |
> > | >
> > | >
> > |
> >
>
>
>
.



Relevant Pages

  • Re: "-33%" dark
    ... agency, or a campaign, when it comes to skin tone? ... It says something ill of us as a society when darkening a person's ... We will control the horizontal. ... If the Clinton campaign wants to control the subliminal fears of ...
    (alt.gathering.rainbow)
  • Re: "-33%" dark
    ... intentionally colorized Obama's skin to darker, ... agency, or a campaign, when it comes to skin tone? ... We will control the horizontal. ... If the Clinton campaign wants to control the subliminal fears of ...
    (alt.gathering.rainbow)
  • Re: Liberal vs. Conservative
    ... democrats were in firm control of the Congress....something that ... I thought the conservatives were in control of congress now? ... Well, yes, but when Clinton was the President, he was able to achieve ...
    (soc.retirement)
  • Re: Liberal vs. Conservative
    ... democrats were in firm control of the Congress....something that ... I thought the conservatives were in control of congress now? ... Well, yes, but when Clinton was the President, he was able to achieve what ...
    (soc.retirement)