2013-02-21 53 views
0

我希望能夠收集URL參數並將其傳遞給SelectParameter。更新ASP:參數值來自URL參數

我覺得像這樣的工作,但我可能是錯在我的翻譯從代碼中的一些代碼,顯示級別

<asp:GridView ID="CountryGridView" runat="server" AutoGenerateColumns="false" CssClass="mGrid" OnRowEditing="CountryGridView_RowEditing"> 
        <Columns> 
         <asp:BoundField ReadOnly="true" DataField="i_SK_Accom" HeaderText="i_SK_Accom" Visible="false" /> 
         <asp:BoundField ReadOnly="true" DataField="Accom_Code" HeaderText="Accom Code" /> 
         <asp:BoundField ReadOnly="true" DataField="Accom_Name" HeaderText="Accom Name" /> 
         <asp:BoundField DataField="OP49_Required" HeaderText="OP49 Required?" /> 
         <asp:BoundField DataField="Weekly" HeaderText="Weekly" /> 
         <asp:BoundField DataField="Daily" HeaderText="Daily" /> 
         <asp:CommandField ShowEditButton="true" ButtonType="Image" EditImageUrl="~/Images/Edit.gif" UpdateImageUrl="~/Images/save.png" CancelImageUrl="~/Images/cancel.png" ControlStyle-CssClass="ImageButton" /> 
        </Columns> 
       </asp:GridView> 
       <asp:SqlDataSource ID="Get_Country" runat="server" ConnectionString="<%$ ConnectionStrings:JFAAdmin %>" SelectCommand="IFACE_JFA_ACCOM" SelectCommandType="StoredProcedure" UpdateCommand="IFACE_JFA_ACCOM" UpdateCommandType="StoredProcedure" > 
        <SelectParameters> 
         <asp:Parameter Direction="Input" Name="Statement" Type="String" DefaultValue="CountryGridSelect" /> 
         <asp:Parameter Direction="Input" Name="i_FK_CountryID" Type="String" DefaultValue="Request["i_FK_CountryID"].Trim().ToString()" /> 
        </SelectParameters> 
       </asp:SqlDataSource> 

的請求[「i_FK_CountryID」]後面的方法。TRIM()。 ToString()是我試圖捕獲通過的URL參數i_FK_CountryID參數

感謝您的任何幫助。

馬庫斯

回答

2

您可以使用QueryStringParameter這個:

<asp:QueryStringParameter 
    Name="i_FK_CountryID" 
    Type="String" 
    QueryStringField="i_FK_CountryID" />