TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sammi taylor
NA
19
0
Show messagebox if no data returned in datagridview
Apr 12 2015 5:31 PM
I have a SearchForm where user enters data in textboxes, btnSearchClick displays data in a datagridivew if there is data in the database. This works fine.
If no data is returned, I need message box to say no search returned, enter a new record.
My messagebox pops up for both when there are records returned AND when there are no records returned.
private
void
btnSearch_Click(
object
sender,
EventArgs
e)
{
//this binds all textboxes to the dgv. This works fine
BindData();
dgvSearch.DataSource = bindingSource1;
//Need help here. Only display messagebox if there are no records returned.
//It pops up each time, even when there are records returned.
if
(dgvSearch.Rows.Count < -1)
{
dgvSearch.ReadOnly =
true
;
}
else
{
MessageBox
.Show(
"No search results returned, clear your search and enter new case"
);
} }
Reply
Answers (
3
)
adding data in combobox from database
String and Double Arrays Simple Spreadsheet Problems