单击链接按钮时如何获取数据键值 [英] how to get datakey value when clicking to link button

查看:231
本文介绍了单击链接按钮时如何获取数据键值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在gridview中有gridview,在子网格中有link按钮,当我单击此lin按钮时,我想获取datakey的值,这是我的代码



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


<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我需要非常迅速的帮助




plzz i need help very quickly

推荐答案

您好,

我看到您有2个gridviews,但是我看不到为任何一个网格指定的任何数据键名称.

应该是这样的,

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,

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



检查此用法以获取更多信息.
希望这会有所帮助.

祝您编码愉快!



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

Happy coding !


这篇关于单击链接按钮时如何获取数据键值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆