ASP.NET - pop up window with grid - Asked By karthick R on 16-Nov-11 07:54 AM

hai..
using the button  click i showed the pop up window ..........after open the pop up window ..... in  the pop up window i have the grid...in the grid i have the link button .... i want ..if i click the link button the row values are passed in to main page
(root page ) textboxs ....... how can i do help me....
Kirtan Patel replied to karthick R on 16-Nov-11 08:06 AM
<asp:GridView ID="GridView1" runat="server" Style="left: 84px; position: relative;
  top: 50px">
  <Columns>
    <asp:TemplateField HeaderText="">
      <ItemTemplate>
        <a href="javascript:openPopup('Info.aspx?id=<%# Eval("ID") %>')">
          <img src="pics/info.gif" border="0px" width="13px" /></a>
      </ItemTemplate>
    </asp:TemplateField>
  </Columns>
</asp:GridView>

dipa ahuja replied to karthick R on 16-Nov-11 08:07 AM
<asp:Button ID="Button2" runat="server" Text="Click" OnClientClick="javascript:window.open('grid1.aspx');" />

grid.aspx

take a gridview and  bind data and in the itemTemplate write this code:
<ItemTemplate>
  <asp:Label ID="Label1" runat="server" Text='<%# Eval("name") %>'></asp:Label>
  <asp:LinkButton ID="linkButton1" CommandName="select" runat="server" Text="Select" />
</ItemTemplate>
and Implement the RowCommand Event:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
  if (e.CommandName == "select")
  {
    GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
 
    string stid = ((Label)row.FindControl("Label1")).Text;
    string name = ((Label)row.FindControl("Label1")).Text;
    Response.Redirect("Page1.aspx?id=" + stid.ToString() + ",sname=" + name);
  }
}
now on page2.aspx retrieve the querystring:
protected void Page_Load(object sender, EventArgs e)
{
  if (Request.QueryString["id"] != null && Request.QueryString["name"] != null)
  {
    TextBox1.Text = Request.QueryString["id"].ToString();
    TextBox2.Text = Request.QueryString["name"].ToString();
  }
}

Jitendra Faye replied to karthick R on 16-Nov-11 08:15 AM

If you want to ashow modalPopUp on click of LinkButton control in GridView then you have to place LinkButton in ItemTemplate of GridView.

Like this-

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:TemplateField >

<ItemTemplate>
<asp:LinkButton ID="lnk" runat ="server" CommandName ="ShowPopup" Text="Open" </asp:LinkButton>
</ItemTemplate>

</asp:TemplateField >
</Columns>
</asp:GridView >

Now Take One Div and modalPopUpExtender in aspx page and place one more GridView in Div Tag.


and set PopupControlID="div1" for modalPopUpExtender

like this-

<Div id="div1" >
//Put controls here
</Div>

<asp:Label id="FakeLabel" runat="Server">

<cc1:ModalPopupExtender ID="Modal1" runat="server"
TargetControlID="FakeLabel"
PopupControlID="div1"
BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>

Now Write this code in .cs file-

protected void GridDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ShowPopup")
{
Modal1.Show();
}
}

Try this code and let me know.

Reena Jain replied to karthick R on 16-Nov-11 08:42 AM
Hi,

check this code
<table width="100%">
<tr>
<td>
<asp:Button ID="HiddenButton1" runat="server" Style="display: none;" />
<ajaxToolkit:ModalPopupExtender ID="modalconfirmIndexparam" runat="server" PopupControlID="pnlCM1"
Drag="true" DropShadow="false" BackgroundCssClass="modalbg" PopupDragHandleControlID="pnlRemarks1"
TargetControlID="HiddenButton1" X="100" Y="550">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel Style="display: none" ID="pnlCM1" runat="server" Width="35%" Height="7%" CssClass="modalBox">
<asp:Panel Style="cursor: hand" CssClass="ModalCaption" ID="pnlRemarks1" runat="server">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:Label ID="lblaction_indexparam" runat="server" Text="Do you want to send it for Approval " style="color:Red"> </asp:Label>
</td>
</tr>
</table>
</asp:Panel>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td align="center" valign="middle">
<asp:Button ID="btnok_param" runat="server" CssClass="button" OnClick="btnOk_param_Click"
Text="Ok" Width="57px" />
<asp:Button ID="btncancel_param" runat="server" CssClass="button" Text="Cancel" OnClick="btncancel_param_Click" />
</td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
</table>


2nd step
Put your gridview in to the ASPX page and put on button field in to the gridview and give the Command Name to the that Button Field Control

3rd step

In the Gridview RowCommand event check for that Command name which you have given in gridview button field you can check it with below code

protected void gvFLDs_RowCommand(object sender, GridViewRowEventArgs e)

{

if(e.commandname == "Test")
{
/// here you can show that modal pop-up control with your code
modalconfirmIndexparam.show();
// here you can put your some logic for the operation
}
}