How to get the clicked LinkButton text in GridView to a label in Popup Panel

我是研究僧i 提交于 2020-02-06 07:54:06

问题


I am using a modal popup inside a GridView for a LinkButton.

what i need is to use the value of clicked LinkButton to appear on a label on Popup panel


回答1:


<asp:GridView ID="GridView1" runat="server"> 
    <Columns><asp:TemplateField>
    <ItemTemplate> 
    <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" Text='<%#Eval("empname") %>'></asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateField></Columns> 
    </asp:GridView>

    <asp:LinkButton ID="lnkDummy" runat="server"></asp:LinkButton>
    <asp:ModalPopupExtender ID="LinkButton1_ModalPopupExtender" runat="server" DynamicServicePath="" Enabled="True" TargetControlID="lnkDummy" PopupControlID="Panel1"> </asp:ModalPopupExtender> 
    <asp:Panel ID="Panel1" runat="server" Height="164px" Width="284px" BackColor="#CCCCFF" ><br /><br /> 
          <center><asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><br /><br /> 
          <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /><br />
          <asp:Button ID="Button1" runat="server" Text="Do"/></center>
    </asp:Panel>


code

        protected void LinkButton1_Click(object sender, EventArgs e)
    {
        LinkButton Lnk = (LinkButton)sender;
        Label2.Text = Lnk.Text;
        LinkButton1_ModalPopupExtender.Show();
    }



回答2:


LinkButton btndetails = (LinkButton)e.CommandSource;

you can now access the btndetails text where u wish to show.



来源:https://stackoverflow.com/questions/8798639/how-to-get-the-clicked-linkbutton-text-in-gridview-to-a-label-in-popup-panel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!