Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i have gridview inside gridview and in the child grid i have link button i want to get datakey value whene i clic to this lin button this is my code


XML
<asp:GridView ID="GridView1"
                            ForeColor="#333333" AutoGenerateColumns="false" ShowFooter="True" runat="server"
                            OnRowEditing="GridView1_RowEditing" DataKeyNames="id"
                            OnRowDataBound="GridView1_RowDataBound"
                            OnRowCancelingEdit="GridView1_RowCancelingEdit"
                            OnRowUpdating="GridView1_RowUpdating"
                            OnRowCommand="GridView1_RowCommand">
                            <EditRowStyle BackColor="#2461BF" />

                            <Columns>

                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <img alt="" style="cursor: pointer" src="Images/plus.png" />
                                        <asp:Panel ID="pnlOrders" runat="server" Style="display: none">

                                            <asp:GridView ID="gvOrders" runat="server" ShowFooter="true" OnRowCommand="gvOrders_RowCommand"
                                                AutoGenerateColumns="false" CssClass="ChildGrid">
                                                <Columns>
                                                    <asp:TemplateField>
                                                        <HeaderTemplate>
                                                            <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/addpm.png" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' />
                                                        </HeaderTemplate>
                                                        <ItemTemplate>

                                                            <asp:LinkButton ID="lnkEditt" runat="server" Text="" CommandName="Edit" ToolTip="Modifier"
                                                                CommandArgument=''><img src="../Images/show.png" /></asp:LinkButton>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:BoundField ItemStyle-Width="150px" DataField="ID_PM" HeaderText="Paramètre de mesure" />
                                                    <asp:BoundField ItemStyle-Width="150px" DataField="UNITE_MESURE" HeaderText="Unité de mesure" />
                                                    <asp:BoundField ItemStyle-Width="150px" DataField="TOLERENCE" HeaderText="Tolerence" />
                                                    <asp:BoundField ItemStyle-Width="150px" DataField="INTERVAL_MIN" HeaderText="Intervale min" />
                                                    <asp:BoundField ItemStyle-Width="150px" DataField="INTERVAL_MAX" HeaderText="Intervale max" />
                                                    <asp:TemplateField>
                                                        <FooterTemplate>
                                                            <img alt="" style="cursor: pointer" src="../Images/plus.png" />
                                                            <asp:Panel ID="pnlOrderss" runat="server" Style="display: none">
                                                                <table style="width: 100%;">
                                                                    <tr>
                                                                        <td>
                                                                            <asp:TextBox ID="txt_libel" runat="server"></asp:TextBox></td>
                                                                        <td>
                                                                            <asp:TextBox ID="txt_type" runat="server"></asp:TextBox></td>
                                                                        <td>
                                                                            <asp:TextBox ID="txt_histoire" runat="server"></asp:TextBox></td>
                                                                    </tr>

                                                                    <asp:LinkButton ID="lnkInsertt" runat="server" Text="" CommandName="InsertNew" ToolTip="Ajouter nouveau station"
                                                                        CommandArgument=''><img src="Images/icon_save.png" /></asp:LinkButton>
                                                                    <asp:LinkButton ID="LinkButton1" runat="server" Text="" CommandName="CancelNeww" ToolTip="Ajouter nouveau station"
                                                                        CommandArgument=''><img src="Images/cancel.png" /></asp:LinkButton>
                                                                </table>
                                                            </asp:Panel>
                                                        </FooterTemplate>
                                                    </asp:TemplateField>

                                                </Columns>


                                            </asp:GridView>

                                        </asp:Panel>
</Columns>
           </asp:GridView>



plzz i need help very quickly
Posted

1 solution

Hi,

I see you have 2 gridviews but i dont see any datakey name specified for either of the grids.

this should be something like,

VB
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
DataKeyNames="Sqnce_id">


Check this for more on the usage.
Hope this helps.

Happy coding !
 
Share this answer
 
Comments
Member 11573837 10-Jul-15 9:52am    
hi manognya kota,
thank you for answering me i have add to my gridview (parent) DataKeyNames="id" but the me i have in the gridview child link button and i want to get datakeynames whene i clic to the last one

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