[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

ASP.NET DataGrid: how to open a new window with binded data

I have a DataGrid.  Here is the server side:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PeopleGrid.DataSource = peopleList;
                //PeopleGrid.Columns[1].Visible = false;
                PeopleGrid.DataBind();
            }
        }

and the client side:

    <asp:DataGrid ID="PeopleGrid" runat="server">
         <Columns>
            <asp:HyperLinkColumn
                 HeaderText="Select a Person"
                 DataNavigateUrlField="Name"
                 DataNavigateUrlFormatString="Details.aspx?id={0}e.Item.Cells[1].Text"
                 DataTextField="Name"
                 Target="_blank"
                 />
         </Columns>

    </asp:DataGrid>

I need to:

(1) make all columns invisible except for the first column that is a list of hyperlinks.
(2) if a hyperlink is clicked, open a new window that contains details on the item clicked.  Below is a page that should be displayed:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Details.aspx.cs" Inherits="PeopleInfo.Details" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Name" runat="server"></asp:Label>
        <asp:Label ID="Address" runat="server"></asp:Label>
        <asp:Label ID="Email" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>

Thank you.
0
Mare22
Asked:
Mare22
1 Solution
 
Easwaran ParamasivamCommented:
You can hide the columns of Grids by setting hiddenfiled as itemtemplate or programatically set column.visible = false. Set the column who has data to be passed as querystring as DataKeynames. Then the ID will be taken even it is hidden.

Please refer below links:

http://www.codeproject.com/KB/grid/Data_presentation.aspx
http://csharpdotnetfreak.blogspot.com/2009/04/linkbutton-gridview-querystring.html
http://csharpdotnetfreak.blogspot.com/2009/04/linkbutton-gridview-querystring.html
http://shirans.blogspot.com/2011/01/gridview-hidden-column-data-access.html



 
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now