Tuesday, July 14, 2009

Pass multiple parameter using HyperLink field in GridView

While using Hyperlink field u can send multiple parameter in Gridview , and then u can retrive it using QueryString Parameter.

here in this Example when user will click on username then it will redirect to
http://xyz.com/ShowUser.aspx?id={0}&city={1} this page
and it will pass customer id and city .






<asp:SqlDataSource id="datasource1" runat="server" SelectCommand="SELECT CustomerID, CompanyName, City FROM Customers"
/>

<asp:GridView id="gridview1" DataSourceID="datasource1" runat="server"
AutoGenerateColumns="False">
<Columns>

<asp:BoundField DataField="CustomerID" HeaderText="BoundField" />

<asp:HyperLinkField
DataTextField="CustomerName"
DataNavigateUrlFields="CustomerID,City"
DataNavigateUrlFormatString=
"http://xyz.com/ShowUser.aspx?id={0}&city={1}" />

</Columns>
</asp:GridView>

No comments:

Post a Comment