473,385 Members | 2,180 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.

Detail view control problem

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 1250
kenobewan
4,871 Expert 4TB
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
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...
6
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...
1
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...
2
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...
0
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...
2
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
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...
2
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...
1
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.