如何将GridView中单击的LinkBut​​ton文本添加到弹出面板中的标签

时间:2012-01-10 04:39:45

标签: c# asp.net .net gridview modalpopupextender

我在GridView中使用模态弹出作为LinkBut​​ton。

我需要的是使用点击的LinkBut​​ton 的值出现在弹出式面板上的标签enter image description here

2 个答案:

答案 0 :(得分:2)

<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>



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

答案 1 :(得分:0)

LinkButton btndetails = (LinkButton)e.CommandSource;

您现在可以访问您希望显示的btndetails文本。