link button inside gridview with poppup functionality

Posted by Ramakrishna188 under ASP.NET on 3/16/2012 | Points: 10 | Views : 3235 | Status : [Member] | Replies : 2
hi
my requirement is
if click a linkbutton inside the gridvew that row data should be displayed in poppup window
needed code in asp.net using c#




Responses

Posted by: Patel28rajendra on: 3/16/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

use gridview row command event and get id from e.command argument and in popup panel bind required data using that id

Thanks

R D Patel

Ramakrishna188, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/16/2012 [Member] Silver | Points: 25

Up
0
Down
Hi Ramakrishna188,
Here is sample code for you.
You have to follow 3 steps:

1.In gridview TemplateField add the linkbutton

<asp:TemplateField>
<HeaderTemplate>
<asp:LinkButton ID="lnkbtnAddtask" runat="server" Text="AddTask+" OnClick="lnkbtnAddtask_Click"></asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="lnkbtnAddSubtask" Text="AddSubTask+" runat="server" OnClick="lnkbtnAddSubtask_Click"></asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>

----------------
2.You have to keep ready a panel for popup
<asp:Panel ID="pnlSubTask" runat="server" Width="430px" Height="230px"
BorderWidth="2px" BorderColor="Black" style="display:none" >
<table style=" width: 430px; height:230px;" cellpadding="1" cellspacing="1"
bgcolor="#F7F7F7" >
<tr bgcolor="#9FECFF">
<td width="50%">
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td style="text-align: right">
<asp:Label ID="Label2" runat="server" Text="Description:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" CssClass="TxtboxText"></asp:TextBox>
</td>
</tr>
<tr>
<td style="text-align: right">
<asp:Label ID="Label3" runat="server" Text="Screen Name:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtScreenName" runat="server" CssClass="TxtboxText"></asp:TextBox>
</td>
</tr>
<tr>
<td style="text-align: right">
<asp:Label ID="Label4" runat="server" Text="Screen Image:"></asp:Label>
</td>
<td>
<asp:FileUpload ID="fileUploadScreenImage" runat="server" />
</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">

</td>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" onclick="btnSubmit_Click" />&nbsp;
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
</table>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="PanelSubtsk_ModalPopupExtender" runat="server" CancelControlID="btnCancel"
BackgroundCssClass="modalBackground" Drag="True" DropShadow="True"
DynamicServicePath="" Enabled="True" PopupControlID="pnlSubTask"
TargetControlID="btnPopPupInspection">
</ajaxToolkit:ModalPopupExtender>
<asp:Button ID="btnPopPupInspection" runat="server" Text="Button" style="display:none" />
---

3.Call the Popup in linkbutton click
protected void lnkbtnAddSubtask_Click(object sender, EventArgs e)
{
LinkButton lnksubtask = sender as LinkButton;
GridViewRow grdRow = (GridViewRow)lnksubtask.NamingContainer;
string Task_id = grdViewTaskDeatils.DataKeys[grdRow.RowIndex].Values["taskid"].ToString();
Label1.Text = Task_id.ToString();
PanelSubtsk_ModalPopupExtender.Show();

}


Thanks,
Sanjay

Ramakrishna188, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response