2012-02-06 16 views
0

のクリックでエンコードされたデータを渡すために:GridViewの:どのように私は以下のようにGridViewのハイパーリンクフィールドでエンコードされたURL文字列を渡ししようとすると、ハイパーリンクフィールド

<asp:HyperLinkField HeaderText="Customer" DataTextField="Customer" DataNavigateUrlFields="Customer" 
    DataNavigateUrlFormatString= "Changes.aspx?customer={0}" SortExpression="Customer" 
    NavigateUrl="~/Client.aspx" /> 

私はこのエラーを取得する:

Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.HyperLinkField does not have a DataBinding event

ハイパーリンクフィールドにエンコードされた文字列を渡す方法はありますか?

代替アプローチ:

また、我々はクエリ文字列内の特殊文字を読むことができる方法はありますか?これを使うと、特定の特殊文字まで読むことができますか?ここで

Request.QueryString["customer"] 

答えて

0

はフィールドバインディングの値は、あなたのケースに合わせて変更さ..私はその上に掲載MSDNのリンクから取られたスニペットが..あなたが必要なものをお見せ、この例に従うと、それはあなたのために働く必要があります..です 例は、このリンクからご返信用MSDN - HyperLinkField.DataNavigateUrlFormatString Property

<h3>HyperLinkField Example</h3> 

     <!-- Populate the Columns collection declaratively. --> 
     <!-- The UnitPrice field values are bound to the   --> 
     <!-- captions of the hyperlinks in the HyperLinkField --> 
     <!-- field column, formatted as currency. The ProductID --> 
     <!-- field values are bound to the navigate URLs of the --> 
     <!-- hyperlinks. However, instead of being the actual --> 
     <!-- URL values, the product ID is passed to the linked --> 
     <!-- page as a parameter in the URL specified by the  --> 
     <!-- DataNavigateUrlFormatString property.    --> 
     <asp:gridview id="OrdersGridView" 
     datasourceid="OrdersSqlDataSource" 
     autogeneratecolumns="false" 
     runat="server"> 

     <columns> 

      <asp:boundfield datafield="OrderID" 
      headertext="Order ID"/> 
      <asp:boundfield datafield="ProductID" 
      headertext="Product ID"/> 
      <asp:hyperlinkfield datatextfield="UnitPrice" 
      datatextformatstring="{0:c}" 
      datanavigateurlfields="ProductID" 
      datanavigateurlformatstring="~\details.aspx?ProductID={0}"   
      headertext="Price" 
      target="_blank" /> 
      <asp:boundfield datafield="Quantity" 
      headertext="Quantity"/> 

     </columns> 

     </asp:gridview> 

     <!-- This example uses Microsoft SQL Server and connects --> 
     <!-- to the Northwind sample database.     --> 
     <asp:sqldatasource id="OrdersSqlDataSource" 
     selectcommand="SELECT [OrderID], [ProductID], [UnitPrice], [Quantity] FROM [Order Details]" 
     connectionstring="server=localhost;database=northwind;integrated security=SSPI" 
     runat="server"> 
     </asp:sqldatasource> 
+0

感謝を貼り付けますが、それは符号化された値として値を送信していません。 –

+0

私はこれの解決策を見つけました。 NavigateUrl = '<%#Eval( "Customer"、 "Clients.aspx?customer =" + Server.UrlEncode(Eval( "Customer"))このように、ハイパーリンクフィールドをTempleteフィールドに変換し、 ").ToString()))%> ' –

+0

cool ..あなたのために働いていないMSDNサイトからの例です。 – MethodMan

関連する問題