I’ve been trying to figure out what’s wrong with this for the past few minutes..
<%@ Page Title="test" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>
<%@ PreviousPageType VirtualPath="~/Top.aspx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<style>
#pagediv { width: 1500px !important; }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#ddModel").change(function () {
var selVal = $(this).find(":selected").text();
var rows = $("#gvTop tr:gt(0)");
alert(selVal);
if (selVal == "ALL") {
$("#gvTop tr").show();
}
else {
var rowToShow = rows.find("td:eq(3)").filter(":contains(" + selVal + ")").closest("tr");
rows.show().not(rowToShow).hide();
}
});
});
</script>
</asp:Content>
Still have no idea right now.
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:DropDownList ID="ddModel" runat="server" DataSourceID="ddmodelsource" DataTextField="Column1" DataValueField="Column1">
</asp:DropDownList>
<asp:GridView ID="gvTop" runat="server" CellPadding="2" CellSpacing="2" GridLines="Vertical">
</asp:GridView>
</asp:Content>
Thats because in a content page, ASP.NET changes the assigned ID to something else. If you View Source of the page you could see that. So, the alternative is to access the controls using
CssClass.For example add a
CssClassto yourGridViewandDropDownListNow access it from jquery like this.