在啓用SqlDataSource
篩選事件default.aspx後,我收到以下錯誤。'ASP.default_aspx'不包含'DS_Filtering'的定義,也沒有擴展方法
'ASP.default_aspx' 不包含 'DS_Filtering',沒有 擴展方法
我失去了任何一個 定義?
請幫
在啓用SqlDataSource
篩選事件default.aspx後,我收到以下錯誤。'ASP.default_aspx'不包含'DS_Filtering'的定義,也沒有擴展方法
'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();
}
我想替換SqlDataSource1.FilterExpression上的撇號。我試過這個SqlDataSource1.FilterExpression.Replace(「{0}」,e.ParameterValues [0] .ToString()。替換(「'」,「''」); 但不起作用 – 2011-05-25 11:34:06
在Page_Load上使用FilterExpression,如: SqlDataSource1.FilterExpression =「city ='」+ DropDownList1.SelectedValue.ToString()。Replace(「'」,「''」); +「'」; – Saurabh 2011-05-25 11:40:21
does not work。I need to Like Like% text%text where quote。 – 2011-05-26 13:08:42
u能張貼其中U曾嘗試這樣的代碼遠。 – 2011-05-25 10:25:36
請張貼您的表單設計。 – 2011-05-25 10:27:48