Click here to Skip to main content
15,846,144 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
While select the gridview row that row data display in another gridview
Aniket Yadav 24-Feb-12 1:59am    
Will you please elaborate what you exactly planning to do?

Hi there.
One thing you should know while asking questions that you should ask the questions properly..

Anyway I am having a solution for your question. Try this:

select the rows data of the first gridview and store it in another datatable and define this data table as datasouce of another gridview...

all the best..
Share this answer

First of all add Linkbutton in gridview commandbutton and gave id="lk"

Now select gridview event rowdatabound like follow code..

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        if (e.Row.RowType == DataControlRowType.DataRow)
            LinkButton lk = (LinkButton)(e.Row.Cells[4].Controls[0]);
            e.Row.Attributes["OnClick"] = ClientScript.GetPostBackClientHyperlink("lk");


Step 3..
add EnableEventValidation="false" like following in ur aspx page
<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

Step 4. Now write code on gridview selected index it will show data 2nd gridview when u select row from one gridview

Share this answer
Hi DG, are you trying to populate a second Gridview, with the data that you have clicked on in the the first GridView?

The scenario is as follows:
Click on a row in GridView1, the data contained in this row is then used to populate a second GridView?

Is this what you are trying to achieve?
Share this answer

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900