how can i do this client side,
OnClientClick of the btnYes will return false if the gridview selected index < 0;
protected void btnYes_Click(object sender, EventArgs e)
{
if (gvCourseDetails.SelectedIndex == -1)
{
ClientScriptManager scriptManager = Page.ClientScript;
scriptManager.RegisterClientScriptBlock(this.GetType(), "alertmessage",
"<script>alert('Select a course above first');</script>");
}
}
Thanks.
The GridView’s selected index will not change without a postback anyway, so you can evaluate it only once on the server side (on page_load or btnYes prerender, etc). It is almost meaningless on the client side.