PC Review


Reply
Thread Tools Rate Thread

DetailsView programmatically enter Insert Mode

 
 
Don
Guest
Posts: n/a
 
      21st Feb 2008
I have a detailsView that I use with a GridView. When a row is
selected I show the GridView with a default mode of Edit. This shows
my fields with text boxes for changing the data. It also has the
update and cancel buttons.

Now I need to put the DetailsView into Insert mode when a button is
clicked. In the button clicked event handler, in the code behind, I
change to insert mode with this code:
dvSingleRow.ChangeMode(DetailsViewMode.Insert);

This takes me into InsertMode but I do not see any of the fields. If
I first select a row and then click the insert button I see all my
fields.

I am using autoGenerateRows=true because by ObjectDataSource is
dynamic and I may have different columns.
 
Reply With Quote
 
 
 
 
Phil H
Guest
Posts: n/a
 
      21st Feb 2008
On 21 Feb, 21:44, Don <chambers...@hotmail.com> wrote:
> I have a detailsView that I use with a GridView. *When a row is
> selected I show the GridView with a default mode of Edit. *This shows
> my fields with text boxes for changing the data. *It also has the
> update and cancel buttons.
>
> Now I need to put the DetailsView into Insert mode when a button is
> clicked. *In the button clicked event handler, in the code behind, I
> change to insert mode with this code:
> dvSingleRow.ChangeMode(DetailsViewMode.Insert);
>
> This takes me into InsertMode but I do not see any of the fields. *If
> I first select a row and then click the insert button I see all my
> fields.
>
> I am using autoGenerateRows=true because by ObjectDataSource is
> dynamic and I may have different columns.


It may be that you need to execute the DataBind method in the code for
the event handler so as to refresh databound controls in response to
state changes.
 
Reply With Quote
 
Don
Guest
Posts: n/a
 
      22nd Feb 2008
I tried that but still get the same results.
I put a breakpoint in the DataBound event and I see that
sender.DataItem is null when I call dataBind from by insert click
event handler.

On Feb 21, 5:14*pm, Phil H <goo...@philphall.me.uk> wrote:
> On 21 Feb, 21:44, Don <chambers...@hotmail.com> wrote:
>
>
>
>
>
> > I have a detailsView that I use with a GridView. *When a row is
> > selected I show the GridView with a default mode of Edit. *This shows
> > my fields with text boxes for changing the data. *It also has the
> > update and cancel buttons.

>
> > Now I need to put the DetailsView into Insert mode when a button is
> > clicked. *In the button clicked event handler, in the code behind, I
> > change to insert mode with this code:
> > dvSingleRow.ChangeMode(DetailsViewMode.Insert);

>
> > This takes me into InsertMode but I do not see any of the fields. *If
> > I first select a row and then click the insert button I see all my
> > fields.

>
> > I am using autoGenerateRows=true because by ObjectDataSource is
> > dynamic and I may have different columns.

>
> It may be that you need to execute the DataBind method in the code for
> the event handler so as to refresh databound controls in response to
> state changes.- Hide quoted text -
>
> - Show quoted text -


 
Reply With Quote
 
fs241690@scarlet.be
Guest
Posts: n/a
 
      24th Mar 2008
It can happen if the DetailsView is linked to a GridView witch
SelectedIndex = -1.
Did you try this ?

GridView1.SelectedIndex = 0;
DetailsView1.ChangeMode(DetailsViewMode.Insert);




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting DetailsView into Insert Mode with default values Nirmal Singh Microsoft ASP .NET 1 13th Oct 2010 07:22 PM
How to enter in Edit Mode programmatically Stefano Gatto Microsoft Excel Programming 2 10th Mar 2009 10:08 AM
DetailsView won't enter Edit mode? =?Utf-8?B?RGF2ZQ==?= Microsoft ASP .NET 1 2nd Jul 2007 10:25 PM
DetailsView - Won't switch to Edit mode if databinding programmatically Mark Stafford Microsoft ASP .NET 1 29th Aug 2006 01:02 AM
Detailsview loses insert mode contents when Insert fails... cannontrodder Microsoft ASP .NET 1 25th Jul 2006 09:38 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:38 AM.