473,586 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 cmdAddPermDefau lt_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) */

dvAppPermission s.Visible = true;
dvAppPermission s.ChangeMode(De tailsViewMode.I nsert);
((Label)dvAppPe rmissions.FindC ontrol("Label7" )).Text =
"SYSDEFAULT "; <-- Fails on this line with NullReferenceEx ception (there
are no controls in the dv)
((Label)dvAppPe rmissions.FindC ontrol("Label8" )).Text = appID;
cmdAddPermDefau lt.Visible = false;
}
protected void dvAppPermission s_ModeChanging( object sender,
DetailsViewMode EventArgs 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)s ender).Visible = false;
cmdAddPermDefau lt.Visible = true;
}
}

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

Thanks,
Mike

Jan 31 '06 #1
0 1108

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

Similar topics

1
3068
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 fields. Code : Label1 Name : Textbox1
0
1239
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 ok. Now what I want is to click on Select Button of DetailView and that row should appear in DetailView, using the same ObjectDataSource, any idea...
0
1159
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 name, which is now shown on the left side next to details. How to hide the column name? 2/
0
3140
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 it. It doesn't work. I have setup 2 sqlDatasource for each Control. the Select Query for SqlDatasource which is bound to the DetailView has the...
2
3762
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 Template Field text box. I tried following in DetailView1_ModeChanged Event but could not succeed. Protected Sub DetailsView1_ModeChanged(ByVal sender...
1
4166
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 updating the progress bar If the form loses focus(i.e selecting any other application) means progress bar is not updating The coding is below
0
1233
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 a onUpdating="xxxxx" inside the <asp:DetailViewand make a sub in the cs file, but while try to run the project, it has the following error, is there...
0
1517
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 (System.Collections.DictionaryEntry o in e.OldValues) { Response.Write("Old Values:" + o.Key.ToString() + "==>" + o.Value + "<br/>"); } foreach...
1
2464
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 like to have Insert from details view. can i do this, please advise me Thanks Ganesh
0
7915
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8204
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7965
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1184
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.