473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DetailsView programmatically enter Insert Mode

Don
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.
Feb 21 '08 #1
3 21042
On 21 Feb, 21:44, Don <chambers...@hotmail.comwrote:
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.
Feb 21 '08 #2
Don
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.ukwrote:
On 21 Feb, 21:44, Don <chambers...@hotmail.comwrote:


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 -
Feb 22 '08 #3
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);


Mar 24 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Playmaker | last post by:
Hopefully someone else has come across this issue. What I have is a SQL Server 2000 back-end. I've created a simple webform which has both Gridview and DataList controls on it populated with a...
2
by: Eric Zhao | last post by:
My details view is in insert mode and my dataset is empty but the details view doesnt show. who can help me, how to do? Also I tried to set the defaultmode to insert mode, but i found i can't...
3
by: Developer | last post by:
I use the RichTextBox and sometimes put it into overwrite mode. I'd like the cursor to show whether its in overwrite or insert mode. I often use Cursor.Current = Cursors.WaitCursor and...
2
by: William LaMartin | last post by:
Is there a way to increase the width of the text boxes for the DetailsView in edit or insert mode? When I put the control in either edit or insert mode, the text boxes to type the new text are...
1
by: cannontrodder | last post by:
I am using a custom business object to deal with inserting, editing, deleting and adding new users to my site which uses the membership class. When I add a new user, it can fail due to the user...
0
by: jobs at webdos | last post by:
I have a formview that will either edit or insert records into a database. when I call the page with a query string ?x= its goes to edit mode and loads data from a datasource in the form and load...
1
by: aekta | last post by:
Hello, How to place a dropdownlist in DetailsView programmatically? Thanks
1
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
When I click the "Edit" hyperlink, my DetailsView doesn't enter Edit mode. It will if I set the DefaultMode="Edit". Any thoughts? Thanks. <asp:DetailsView ID="DetailsView1"...
0
by: Nirmal Singh | last post by:
How can I (programattically) set a Detailview control into Insert mode and set data to default values? Nirmal
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.