Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Verify GridView item is selected 1

Status
Not open for further replies.

lance59

IS-IT--Management
Mar 6, 2007
50
0
0
US
Looking to verify that any item or row in gridview is selected before moving to the next page.

If GridView1.?????????? = True Then
Dim S2 As String = Server.UrlEncode(u)
Response.Redirect("Registration.aspx?class_Reg1=" & S2)
Else
Response.Write("<font color=""Red""><i> Please select at least one row </i> </font>")
End If

TIA
 
Use the SelectedIndex property to determine if a row is selected. From MSDN:

"The zero-based index of the selected row in a GridView control. The default is -1, which indicates that no row is currently selected."

So:

If GridView1.SelectedIndex > -1 Then
Dim S2 As String = Server.UrlEncode(u)
Response.Redirect("Registration.aspx?class_Reg1=" & S2)
Else
Response.Write("<font color=""Red""><i> Please select at least one row </i> </font>")
End If

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top