How to do a validation for empty grid view?

Posted by Annagoldtech under VB.NET on 4/25/2013 | Points: 10 | Views : 1244 | Status : [Member] | Replies : 2
Hi,

I am working on VB.Net Framework 1.1.
I have a page with file upload, button upload and gridview.
When "Upload" button is clicked, i need to show the attachments in grid view.
If file is not attached, i need to show a error message.

In my code behind i wrote this code:
If dgTeam.Items.Count = 0 Then
DisplayPrompt("Please upload attachments")
End If

If ddlEvaluate.SelectedIndex = 0 Then
DisplayPrompt("Please select an evaluator")
End If

My issue is: if i didnt select evaluator and click submit button, the error message of file upload is display properly.
but if i select my evaluator and click submit button, i am not getting error message and my grid view is not validating as per my command.

Can u guys help me to resolve this issue. Either the above code or please suggest me to write validation in javascript.

Thanks.




Responses

Posted by: Jitendrasoft09 on: 4/26/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
HI,
Best approach is to put two breakpoints in your two if conditions, check what value is coming and why not firing. If not works you can try to validate with javascript or jquery, please refer below link that would be helpful for you.
http://www.codeproject.com/Questions/300252/how-to-validate-a-dropdownlist-using-javascript

Jitendra Kumar
If my post helps you, plz mark as an answer.

Annagoldtech, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Annagoldtech on: 4/28/2013 [Member] Starter | Points: 25

Up
0
Down
@Jitendra,

The above url is for validating dropdown list and list items, but my concern is validating the gridview.

I want to show the error message when file is not attached in the gridview.

Thanks,

Annagoldtech, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response