开发者

If DropDownList Selected Index Changed, hide gridview rows

How do i call 开发者_如何学Cthe event dropdownlist.selectedindex.changed on client-side?

Can this be done with javascript/jquery?

What should I include in the markup to enable javascripts?

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

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

I was looking to do something like this

IF SelectedValue = 2, Hide Row 1,2,3, and 4
IF SelectedValue = 3, Hide Row 11,21,31, and 41


You can attach the onchange event to javascript on your dropdown. Then whenever your selected Index changes it will fire and call the javascript update method, in which you can hide that particular row.

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

here is 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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜