Click here to Skip to main content
15,905,144 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to fetch the value from gridview and then display it in another gridview
Posted
Updated 21-Jun-12 21:39pm
v2
Comments
Sandeep Mewara 22-Jun-12 4:59am    
ASP.NET it looks like? same page display or other?

1 solution

look this simple example i think it will help you

XML
<asp:GridView
        id="GridView1"
        DataKeyNames="Id"
        DataSourceID="srcGridView1"
        AutoGenerateSelectButton="true"
        SelectedRowStyle-CssClass="selectedRow"
        Runat="server" />

    <asp:GridView
        id="GridView2"
        DataSourceID="srcGridView2"
        Runat="server" />

    <asp:SqlDataSource
        id="srcGridView1"
        ConnectionString="<%$ ConnectionStrings:str1 %>"
        SelectCommand="SELECT Id, Name FROM UrTable1"
        Runat="server" />

    <asp:SqlDataSource
        id="srcGridView2"
        ConnectionString="<%$ ConnectionStrings:str1 %>"
        SelectCommand="SELECT FieldName1,FieldName2 FROM UrTable2
            WHERE Id=@GridView1Id"
        Runat="server">
        <SelectParameters>
        <asp:ControlParameter
            Name="GridView1Id"
            ControlID="GridView1"
            PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>
 
Share this answer
 
Comments
abhilasha mourya 22-Jun-12 4:12am    
i want to display the values by searching them through a textbox. like when i enter some value in textbox and click on search button the data will retreive from the gridview in some new gridview

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