2010-04-06 82 views
4

我有一個網格和下拉列表。我想通過dropdownlist的選擇過濾網格中的值。如何才能做到這一點? 我的代碼是這樣的將下拉列表的選定值傳遞給aspx中的參數

<asp:DropDownList ID="DDLVisitedVol" runat="server" AutoPostBack="true" DataSourceID="DsVisitedVol" 
      DataTextField="VisitedVol" DataValueField="VisitedVol" 
      Width="244px"> 
     </asp:DropDownList> 

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="" 
      ProviderName="" 
      SelectCommand="SELECT [ID],[UserName], [Email], [visitedVol] FROM [HitTracker] where [email protected] "> 
     <SelectParameters> 
       <asp:Parameter Name="VisitedVol" Type="String"/> 
     </SelectParameters> 

我如何可以通過下拉列表來@VisitedVol的設定值。 如果有人知道請幫幫我。 TANK YOU YOU

回答

-1

Basiclly,您必須處理ddl selectedIndexChanged事件,並在使用ddl選定項目值過濾後綁定數據。

這裏是使用類似的代碼在SqlDataSource一個很好的示例代碼段您已經發布:

http://www.15seconds.com/issue/060323.htm

[看文章的結尾]

5

使用ControlParameter:

<asp:ControlParameter ControlID="DDLVisitedVol" Name="VisitedVol" PropertyName="SelectedValue" Type="String"/> 
+0

@nix我發佈這個你做到了..所以+1 .. – 2010-04-06 12:17:29

3

ControlParameter是你的朋友:

<asp:ControlParameter Name="VisitedVol" ControlID="DDLVisitedVol" PropertyName="SelectedValue"/> 
相關問題