Click here to Skip to main content
15,924,507 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
checkbox selected row or rows to another girdview in another page please send me the code if you have it

page 1

XML
<table>
        <tr>
            <td>
                <table>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td>
                                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3"
                                            GridLines="None" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"
                                            CellSpacing="1"
                                            AutoGenerateSelectButton="false" >
                                            <Columns>
                                                <asp:TemplateField>
                                                    <ItemTemplate>
                                                        <input type ="checkbox" value="" onclick='addthis(this,<%#Eval("EmpSalary") %>)' />

                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <ItemTemplate>
                                                        <%# Eval("EmpName") %>
                                                    </ItemTemplate>
                                                </asp:TemplateField>

                                                <asp:TemplateField HeaderText="Emp Salary">
                                                    <ItemTemplate>
                                                       <%# Eval("EmpSalary") %>
                                                    </ItemTemplate>
                                             </asp:TemplateField>
                                            </Columns>
                                            <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                                            <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                                            <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                                            <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                                            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                                        </asp:GridView>
                                        <input type="text"  id="resdiv" value="0" />
                                        <asp:HiddenField ID="hidden1" runat="server" />
                                        <asp:Button ID="bbbtbn" runat="server" Width="50px" onclick="bbbtbn_Click" />
                                        <input type="text" id="txtxt"  />

                                    </td>
                                </tr>
                            </table>

                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>



page 2

XML
<table>
                                <tr>
                                    <td>
                                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3"
                                            GridLines="None" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"
                                            CellSpacing="1"
                                            AutoGenerateSelectButton="false" >
                                            <Columns>

                                            </Columns>
                                            <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                                            <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                                            <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                                            <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                                            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                                        </asp:GridView>


                                    </td>
                                </tr>
                            </table>
Posted

first of all bind gridview on page_load
then
In the click event write the below code

C#
foreach(Gridviewrow gvr in Gridview1.Rows)

{

if(((CheckBox)gvr.findcontrol("CheckBox1")).Checked == true)

{

int uPrimaryid= gvr.cells["uPrimaryID"];
}
}


you will get primaryid

call selectdata(uPrimaryid) it will return data set

session["ds"]=selectdata(uPrimaryid) or

add it in querystring ...aspx?id=uPrimaryid

redirect to another page

get querstring request.querstring("id")

call method selectdata(uPrimaryid)

bind using gridview.databind();
 
Share this answer
 
Hi,
You can get your solution by using following steps.
1. Page1
on clicking of checkbox please store primary id of row and pass it to the second page by either of way(findcontrol of previous page, session, cookie, querystring).
Page2
once you have rowid hit your database with that row id and get your result bind in grid view.


2. make a datatable of row that has been selected
store that in session
bind that session datatable to gridview.

Pleas mark as answer when you done with your problems.
 
Share this answer
 
create an object just like ur gridview columns.when u checked a row in gridview bind that data to object. and after when u r navigating from one page to anther keep this object in page session and bind this object to gridview in another page.the best thing is use objects and list arrays.
 
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