Visual Studio 2010 を使用して ASP.net と c# を使用する
こんにちは、誰かが私を助けてくれることを願っています。基本的に、列の1つにリンクボタンがあるグリッドビューを持つページがあります。私がやろうとしていることは次のとおりです。ユーザーがリンクをクリックすると、参照先の PDF ファイルが site.master を使用して新しいページに読み込まれます。以下は私が現在持っているコードです。
開始ページ
SelectCommand="SELECT * FROM [Guides] WHERE (([Display] = ?) AND ([Media_Document] = ?))">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="true" Name="Display"
QueryStringField="checkbox" Type="Boolean" />
<asp:QueryStringParameter DefaultValue="Document" Name="Media_Document"
QueryStringField="Media_Document" Type="String" />
</SelectParameters>
</asp:AccessDataSource>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server">
</asp:ObjectDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="ID" CssClass="mGrid" RowStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt"
DataSourceID="AccessDataSource1" Width="225px" style="text-align:left"
GridLines="None" >
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
<Columns>
<asp:BoundField DataField="Guide" HeaderText="Guide" SortExpression="Guide" />
<asp:HyperLinkField DataNavigateUrlFields="File_location"
DataNavigateUrlFormatString="Guides.aspx?File_location={0}"
Target="content" Text="Link" />
</Columns>
<RowStyle CssClass="pgr"></RowStyle>
</asp:GridView>
</div>
このコードはリンクを正しく生成します。 Guides.aspx?File_location=blahblahblah.pdf
リンク先ページ
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<object width="800" height="800" data="File_Location"></object>
</asp:Content>
意味のある変数File_location
が認識されないため、これは機能しません。コードビハインドでc#を使用して場所を取得できましたが、それをページに表示するにはどうすればよいですか?
何か案は?
コードビハインド
public partial class Guides : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string Location = Request.QueryString.ToString();
File_location(Location);
}
public void File_location(string location)
{
string File_Location = location.Substring(location.IndexOf('=') + 1);
}
}