Rajesh Gonugunta
Rajesh Gonugunta

Reputation: 13

asp.net gridview inside radio button select true or false

 $(document).ready(function () {

        $("#Button_Edit").click(function () {
            var radio1 = $("#GridView_Customer_Project_List:radio[id^='RadioButton_Select']");
            if (radio1.is(':checked') == true) {
                alert("Selected");

            }
            if (radio1.is(':checked') == false) {
                alert("Not selected");                 
            }             

        });

    });

in the above code always going to not selected alert message, i want to both validation

Upvotes: 0

Views: 1009

Answers (2)

Adeel Shekhani
Adeel Shekhani

Reputation: 1105

I think you are not selecting the GridView properly.Try this:

var count=$('table[id*="GridView_Customer_Project_List"] input[type="radio"]:checked').length;
if (count > 0){
 alert ('Selected');
}
else
    alert('Not Selected');

Upvotes: 1

Pooja Shrigod
Pooja Shrigod

Reputation: 165

Try the following code

$(document).ready(function () {

    $("#Button_Edit").click(function () {
        var radio1 = $("#GridView_Customer_Project_List:radio[id^='RadioButton_Select']");
        if (radio1.is(':checked') == true) {
            alert("Selected");

        }
       else
        {

        if (radio1.is(':checked') == false) {
            alert("Not selected");                 
        }             
        }
    });

});

Upvotes: 0

Related Questions