Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
I have two pages. Grid view page and profile page.
 
In the first page, there is one databound field(id), and the hyperlink(profile).
 
If i click the hyperlink i can view the full staff details in separate web page(using "id" as a session)
 
Plz help me...
 
Thank you in advance
Posted 11-Feb-13 18:52pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I am assuming you need an example of Grid View and Details View. Please have a look at following link:
GridView and Details View[^]
http://msdn.microsoft.com/en-us/library/ms972814.aspx[^]
GridView-DetailsView (Master/Detail) Control[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Default.aspx
__________________________
 
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        onrowcommand="GridView1_RowCommand">
        <Columns>
            <asp:BoundField DataField="id" HeaderText="id" />
            <asp:BoundField DataField="name" HeaderText="name" />
            <asp:BoundField DataField="address" HeaderText="address" />
            <asp:TemplateField>
            <ItemTemplate>
            <asp:LinkButton ID="XXXXX" runat="server" Text="NEW PAGE" CommandName="AA" CommandArgument='<%#Eval("id") %>' />
 

            </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
 
Default.aspx.cs
_________________________________
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
 
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            BindGridview();
    }
    protected void BindGridview()
    {
        using (SqlConnection con = new SqlConnection("--------"))
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("Select * FROM TEST", con);
            SqlDataReader dr = cmd.ExecuteReader();
            GridView1.DataSource = dr;
            GridView1.DataBind();
            con.Close();
        }
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "AA")
        {
            string id = e.CommandArgument.ToString();
            //if u want to use querystring//
            Server.Transfer("Default2.aspx?id=" + id);
            // if u want to use session//
            // Session["id"] = id.ToString();
            // Server.Transfer("Default2.aspx");
            
        }
 
    }
}
 

Default2.aspx.cs
_____________________________
protected void Page_Load(object sender, EventArgs e)
    {
        string id=Request.QueryString["id"];//for query string
        //string id1 = Session["id"].ToString();//for session
    }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 334
1 Kornfeld Eliyahu Peter 325
2 Maciej Los 239
3 OriginalGriff 188
4 King Fisher 185
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100