If the selected DropDownList index is changed, hide the gridview rows

How to raise dropdownlist.selectedindex.changed event on client side?

Can this be done using javascript / jquery?

What should I include in the markup for javascripts?

<%@ Page Title="Report" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Report.aspx.cs" Inherits="Report" %>

 <%@ PreviousPageType VirtualPath="~/Top.aspx" %>

I was looking for something like this

IF SelectedValue = 2, Hide Row 1,2,3, and 4
IF SelectedValue = 3, Hide Row 11,21,31, and 41
+3
source share
1 answer

You can attach the event onchangeto javascript in the dropdown list. Then, whenever your selected Index changeslights up and the javascript method is called update, in which you can hide this particular line.

<asp:DropDownList ID="ddl" onchange="javascript:update();"

here is the javascript code

<script language="javascript" type="text/javascript">
    function update() {
        var ri = 2; // I suppose that you know the Index of Row Which you want to hide
        var grd = document.getElementById('<%= grd.ClientID %>');
        grd.rows[ri].style.display = 'none';
    }

</script>
+3
source

All Articles