[ACCEPTED]-How to check if any row is selected from GridView?-rowdatabound
Accepted answer
You can check like...
if (GridView1.SelectedValue != null)
{
//Row is Selected
}
0
You can try something like this:
If GridView1.SelectedRows.Count > 0 Then
' yourcode here - a row is selected
Else
' yourcode here - NO row is selected
End If
0
Better this:
if(GridView1.SelectedIndex < 0)
{ its -1 and no row is selected.}
else
{its >= 0 and a row is selected}
testing for != null
will throw an exception 1 if the selected value is null
.
you can also check like this
if(GridView.SelectedIndex >= 0)
{
string result = "Selected";
}
else
{
string result = "Not Selected";
}
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.