我希望能够收集一个URL参数并将其传递给SelectParameter。
我认为这样的事情会起作用,但我将一些代码从Code Behind转换为显示级别的方法可能是错的
<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>
Request [“i_FK_CountryID”]。Trim()。ToString()是我试图捕获的URL参数,作为i_FK_CountryID参数
感谢您的帮助。
马库斯
答案 0 :(得分:2)
您可以使用QueryStringParameter:
<asp:QueryStringParameter
Name="i_FK_CountryID"
Type="String"
QueryStringField="i_FK_CountryID" />