473,320 Members | 2,117 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,320 software developers and data experts.

detailview loses components after refresh

I have a detailview, with several template columns in it.

It's setup so that a user views info from a datagrid, and if they want
to add another row, they click a button. The button causes a
detailview to open up, in insert mode, they enter the data, hit insert,
and the detailview goes away. Their data now appears in the gridview.
When the user clicks the button to open the detailview, a few databound
labels in 2 of the detailview's template insert columns get set from
the code (see below)

This all works, the first time thru. However, on the second time
through, opening the detailview, I get an unhandled exception when I'm
trying to set the labels to a value. Upon further inspection, I notice
that the detailview has no children controls. This happens whether I
open the detailview, insert data, and save, then re-open the detailview
(failure happens here), or if I just open the detailview, hit the
cancel option, and open the detailview again (failure happens here).

Here is some relevant code, let me know if there's anything else
needed:

protected void cmdAddPermDefault_Click(object sender, EventArgs e)
{
/* This is the button press that makes the detailview visible,
the button invisible, sets two fields within the detailview (Label7 and
Label8 are labels in the insert template) */

dvAppPermissions.Visible = true;
dvAppPermissions.ChangeMode(DetailsViewMode.Insert );
((Label)dvAppPermissions.FindControl("Label7")).Te xt =
"SYSDEFAULT"; <-- Fails on this line with NullReferenceException (there
are no controls in the dv)
((Label)dvAppPermissions.FindControl("Label8")).Te xt = appID;
cmdAddPermDefault.Visible = false;
}
protected void dvAppPermissions_ModeChanging(object sender,
DetailsViewModeEventArgs e)
{
/* when the mode of the detail view is changing, I'm checking to
see if it's going back to read only, if so, make it not visible, and
make the add button visible */
if (e.NewMode == DetailsViewMode.ReadOnly)
{
((DetailsView)sender).Visible = false;
cmdAddPermDefault.Visible = true;
}
}

Any pointers as to why the second time through the detailsview there
are no controls?

Thanks,
Mike

Jan 31 '06 #1
0 1095

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

Similar topics

1
by: Luqman | last post by:
The detailview control is combination of textboxes and labels, while detailview is in edit mode, how can I change the textbox value through code ? For example: My detailView has following...
0
by: Luqman | last post by:
I have used a single objectDataSource for GridView and DetailView, and when I load the page, the GridView shows all the entries of Invoice, and DetailView shows the 1st entry of Invoice, thats all...
0
by: =?Utf-8?B?THVib21pcg==?= | last post by:
Hi, I have a GridView and Dataview controls. If user clicks on a row in GridView, the details will be shown in DetailView. 1/ I want to show in DetalView only details field - without column...
0
by: Deepak Palkar | last post by:
Hi I have Gridview and DetailView both on one page. I am showing the list in the Gridview and the particular record in DetailView. the problem is When i EDIT on the DetailView and try to UPDATE...
2
by: Luqman | last post by:
Hi, Any Idea how to Display Todays Date in DetailView Template Field while Inserting ? For example: When I click on New Button of DetailView Control, I need to display Today's Date in a...
1
by: Manikandan | last post by:
Hi, I have a form with progress bar. I'm querying sql server with large number of records(around 1 lakh) for export The records are written to a text file I'm showing the process running by...
0
by: LamSoft | last post by:
By Double clicking the object detailview, it will auto make a sub-procedure called XXXXX_Selecting, however I want a sub-procedure to be called while the detailview is being updated, so that i add...
0
by: LamSoft | last post by:
In the object of detailView, i added a function to check the values during itemUpdating, the source is: protected void test2(object sender, DetailsViewUpdateEventArgs e) { foreach...
1
by: Ganesh | last post by:
Hi There, I use detailView to edit, insert and delete data. It gets value from datagrid.selectedvalue. How can i insert a record initially. If there is not any record in the grid, still i would...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.