473,803 Members | 3,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detail view control problem

32 New Member
Hello,

I have a simple vb.net 2005 application using an SQLserver database

There is a form , employees that has a grid view and a detail view control
The grid displays data and has a "Select" link as the leftmost column. Clicking on this displays employee details in the detail view.

The detail view further has Edit, Delete and New links, that help to maintain data.

My problem is this -

when the last employee record is deleted, the detail view must go to insert mode , so that the user can enter fresh data.

The defaultmode property of thd detail view is set to "Read only " at design time.

Right now, when the last record is deleted, the detail view disappears from the screen , as it is still in read-only mode

I have written the following code, it works in all cases, except when the last record on screen is deleted.

What am I missing ?

Expand|Select|Wrap|Line Numbers
  1.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  2.         Dim mycount As Integer = GridView1.Rows.Count
  3.         If mycount > 0 Then
  4.             DetailsView1.DefaultMode = DetailsViewMode.ReadOnly
  5.         Else
  6.             DetailsView1.DefaultMode = DetailsViewMode.Insert
  7.         End If
  8.         DetailsView1.Visible = True
  9.     End Sub
Any help highly appreciated
Nanda
Nov 25 '08 #1
1 1278
kenobewan
4,871 Recognized Expert Specialist
If the row count is zero based, having one row leads to a 0 count. In that case not having any rows can lead to a count of -1. Either way write mycount to test.
Nov 27 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3578
by: John Baker | last post by:
Hi: Stuck on another thing. On a report I am creating, I want to make the detail section one line vertically. However, in design view, I click on the page Footer Bar ,grab it with the "double arrow and cross", and try to move it up and while it moves, as soon as I release it jumps back to its original position. For some reason the property "height" for the detail section is stuck at a minimum of .5833". The height will go LARGER but...
6
2709
by: Mike MacSween | last post by:
I have a report based on: PARAMETERS Forms!frmProductions!ProdID Long; SELECT Sum(qryRoleEvent.Fee) AS SumOfFee, First(qryMusician.LastName) AS LastName, First(qryMusician.FirstName) AS FirstName FROM (qryEvent INNER JOIN qryRoleEvent ON qryEvent.EventID = qryRoleEvent.EventID) INNER JOIN qryMusician ON qryRoleEvent.MusoID = qryMusician.MusoID WHERE (((qryEvent.ProdID)=!!)) GROUP BY qryMusician.MusoID
1
5774
by: Tom | last post by:
In the Developers Handbook, Getz provides a way to create a survey report that displays either a line, Yes/No or multiple choice for each question. It's done by placing three controls (one for each type of answer) in the report's detail section and then making the control appropriate for each question visible in the Format event of the detail section. Can this be simulated in a form? There's no Detail Format event for a form but can it be...
2
7212
by: Dan | last post by:
I found an example of a A Master/Detail DataGrid Control in a MSDN magazine ( http://msdn.microsoft.com/msdnmag/issues/03/08/CuttingEdge/ ). The code is in c# so I converted it to vb.net and I am having a problem with the view statement. What have a done wrong? Any ideas would be appreciated. C# code: void BindDetails() { DataTable table;
0
3244
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another way... here is my code on how I did it to help anyone starting out get an idea of how to use virtual mode in ..NET 2.0 Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared
2
4704
by: Luqman | last post by:
How can I put GridView and DetailView control to Edit Mode with one click of button ? I don't want to show built-in Edit Buttons of above controls. Best Regards, Luqman
4
5936
by: 2D Rick | last post by:
In Access2003 and XP. My forms detail section hides behind the header when I scroll down to see controls off screen. This is similar to freezing a pane in Excel. I'd rather this did not happen but can't find the property that controls this. When the form first opens some of the controls are behind the header and scrolling is required to see them. Help, thanks, RICK
2
1875
by: Sin Jeong-hun | last post by:
I often use detail view of the ListView control to display tabular data (is there any better way?) Many real-world applications display buttons, progress bars or dropdown lists in the columns, but it seems like ListView only allows texts. I guess if I can only know the exact bounds of the columns, I could overlay other Windows controls on it making the simmilar effects. But the problem is I can't know the exact amount of change when the...
1
1183
by: neoupadhyay | last post by:
hi friend, I m using asp.net2.0 with c#, I have a form where i have multiview control, and on a multiview control.....i have a combo box, and a detail view. now on the select idex change of combo box i write the below code, where i got error... ie. I got This Error msg "Both DataSource and DataSourceID are defined on 'DetailsView3'. Remove one definition" my code is :- protected void cboLoanSelect_SelectedIndexChanged(object...
0
10542
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10309
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10289
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7600
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6840
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5496
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.