问题描述
|
在default.aspx上启用“ 0”过滤事件后,出现以下错误。
\'ASP.default_aspx \'不包含
\'DS_Filtering \'的定义,否
扩展方法
我有什么想念的吗?
请帮忙
解决方法
下面可能会告诉您这是如何工作的,请检查:
<html xmlns=\"http://www.w3.org/1999/xhtml\" >
<head runat=\"server\">
<title>ASP.NET Example</title>
</head>
<body>
<form id=\"FORM1\" runat=\"server\">
<p>Show all employees with the following title:
<asp:DropDownList
id=\"DropDownList1\"
runat=\"server\"
AutoPostBack=\"True\">
<asp:ListItem>Sales Representative</asp:ListItem>
<asp:ListItem>Sales Manager</asp:ListItem>
<asp:ListItem>Vice President,Sales</asp:ListItem>
</asp:DropDownList></p>
<asp:SqlDataSource
id=\"SqlDataSource1\"
runat=\"server\"
ConnectionString=\"<%$ ConnectionStrings:NorthwindConnection %>\"
SelectCommand=\"SELECT EmployeeID,FirstName,LastName,Title FROM Employees\"
FilterExpression=\"Title=\'{0}\'\" OnFiltering=\"SqlDataSource1_Filtering\">
<FilterParameters>
<asp:ControlParameter Name=\"Title\" ControlId=\"DropDownList1\" PropertyName=\"SelectedValue\"/>
</FilterParameters>
</asp:SqlDataSource><br />
<asp:GridView
id=\"GridView1\"
runat=\"server\"
DataSourceID=\"SqlDataSource1\"
AutoGenerateColumns=\"False\">
<columns>
<asp:BoundField Visible=\"False\" DataField=\"EmployeeID\" />
<asp:BoundField HeaderText=\"First Name\" DataField=\"FirstName\" />
<asp:BoundField HeaderText=\"Last Name\" DataField=\"LastName\" />
</columns>
</asp:GridView>
<asp:Label ID=\"Label1\" runat=\"server\" Text=\"Label\"></asp:Label>
</form>
</body>
</html>
服务器端:
protected void SqlDataSource1_Filtering(object sender,SqlDataSourceFilteringEventArgs e)
{
Label1.Text = e.ParameterValues[0].ToString();
}