Link to home
Create AccountLog in
Avatar of RunForrestRun
RunForrestRunFlag for United States of America

asked on

Trying to validate datagrid.

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.

Thanks,
Run Forrest
Avatar of RunForrestRun
RunForrestRun
Flag of United States of America image

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer