I’m trying to write a simple script so that before the user has to select a row in the Gridview before being able to continue to the next Page. If they haven’t selected a row and they press the button, the page only shows an error messge. As far as I know, none of the Validation controls will work with this type of event. Here’s my code: (I left out namespaces for clarity)
public partial class Manage : System.Web.UI.Page
{
public class Verify
{
private int verifyClick;
public int VerifyClick
{
get
{ return verifyClick; }
set
{ verifyClick = value; }
}
}
Verify selectAction = new Verify();
public void Page_Load(object sender, EventArgs e)
{
}
public void Button1_Click(object sender, EventArgs e)
{
if (selectAction.VerifyClick != 1)
{
Label1.Text = "You must Select a Lesson before choosing to Continue";
}
else
{
Response.Redirect("ManageContent.aspx?selectedLesson=" + GridView1.SelectedDataKey.Value.ToString());
}
}
public void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
selectAction.VerifyClick=1;
}
}