We help IT Professionals succeed at work.

Trying to validate datagrid.

Last Modified: 2008-04-24
Hello EE Experts,
I have a telerik radgrid on my form. What I am trying to do is make sure the client has data on the datagrid before moving off that page to another page. What I HAVE to have is 5 years of address history before they can click the Next Page button. I have 8 columns -- Address, City, State, Zip, County, Country, FromDate, and ToDate. I'm trying to do my validation to check for 5 years of history in the btn_Next click event. Is that possible? Right now I'm getting that "Object reference not set to an instance of an object" error for my Peter Blum textbox that's inside my grid. I'm getting the error in my click event. I'm having trouble referencing that textbox in my click event even though I'm using the FindControl method. I'm using VS 2003 ASP.Net 1.1 with Telerik and PeterBlum components. Awesome controls. Any information will be greatly appreciated. I've already contacted telerik and they emailed me back but I couldn't understand too well what they told me to do. Oh, and the reason I am trying to do this in the Next Page click event is because there are not a lot of other controls on the page. I just have some textboxes at the top of the page for current address information, and then of course my grid and then a button at the bottom to move to next page. So I'm trying to validate to check for 5 years history in the click event. I do have validators on the textboxes embedded in the grid when you click "Add new record" and open it and they are working great but that is ONLY if you have data on the grid -- right now it will happily let you move to another page if there's no data on the grid. I'm racking my little brain.

Run Forrest
Watch Question


Figured it out, here's the code if anyone needs it.

Private Sub btn_Next_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Next.Click

If (ResHistoryGrid.MasterTableView.OwnerGrid.Items.Count = 0) Then
    Me.popupWin2.AutoShow = True 'a little popup window util I"m using from Tomas Petricek @ tomasp.net to alert user...
    Me.popupWin2.Title = "No Address History!"
    Me.popupWin2.Message = "You DO NOT have any Address History yet. Please add 5 years of history."
    btn_Next.Enabled = False 'disable the Next Page button so user can't move off page
End If

End Sub
This one is on us!
(Get your first solution completely free - no credit card required)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.