Collecting Data in a New Window
There are various cases in which you may want to get the content of the cells in a selected grid row (clicking a hyperlink in that row), pass this content in a query and open the results in a new window.Such scenario is easily handled by Telerik RadGrid. Here is a sample implementation technique:
-
We use GridHyperLink column with Target property set to**_blank** to open a new window on user click;
-
Hooking the ItemDataBound event of the grid we store the values of the cells for the clicked row in the NavigateUrl property of the Hyperlink in the GridHyperLinkColumn (passing them as QueryString arguments);
-
In the page to which we navigate (Resources.aspx) we have five labels. Their text is set on PageLoad and Not Page.IsPostBack to display the details for the clicked row;
-
The clicked row will be selected as we enabled client side selection (setting ClientSettings -> Selecting -> AllowRowSelect = True).
Default file (ASPX and code-behind)
<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server">
<SelectedItemStyle BackColor="Aqua" />
<MasterTableView AutoGenerateColumns="True">
<Columns>
<telerik:GridHyperLinkColumn HeaderText="Select row" Target="_blank" Text="Display details in new window"
UniqueName="HyperLinkColumn">
</telerik:GridHyperLinkColumn>
</Columns>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" />
</ClientSettings>
</telerik:RadGrid>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [PostalCode] FROM [Customers]">
</asp:SqlDataSource>
Resources file (ASPX and code-behind)
<div>
<b>Company name:</b>
<br />
<asp:Label ID="lblCompanyName" runat="server" Text=""></asp:Label>
<br />
<b>Contact name:</b>
<br />
<asp:Label ID="lblContactName" runat="server" Text=""></asp:Label>
<br />
<b>Contact title:</b>
<br />
<asp:Label ID="lblContactTitle" runat="server" Text=""></asp:Label>
<br />
<b>Address:</b>
<br />
<asp:Label ID="lblAddress" runat="server" Text=""></asp:Label>
<br />
<b>Postal code:</b>
<br />
<asp:Label ID="lblPostalCode" runat="server" Text=""></asp:Label>
</div>