Modal Popup in Gridview

I am about to destroy a segment of code in one of my projects, but before I do, I think it can help someone:

<asp:GridView ID="gvwProjects" runat="server" ShowHeader="false" EnableTheming="false" AutoGenerateColumns="false" OnRowCreated="gvwProjects_RowCreated" BorderWidth="0px" OnSelectedIndexChanged="gvwProjects_SelectedIndexChanged">

AutoGenerateColumns="false" OnRowCreated="gvwProjects_RowCreated" BorderWidth="0px" OnSelectedIndexChanged="gvwProjects_SelectedIndexChanged">

<Columns>

<asp:TemplateField>

<asp:TemplateField><ItemTemplate>

<asp:ImageButton ID="imgProject" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' ImageAlign="Left" AlternateText='<%# Eval("ImageAlternateText") %>' CommandName="Select" Style="padding-right: 15px" />

ImageAlign="Left" AlternateText='<%# Eval("ImageAlternateText") %>' CommandName="Select" Style="padding-right: 15px" />

<asp:Label ID="lblProject" runat="server" Text='<%# Eval("Abstract") %>' />

<asp:Panel ID="pnlProject" runat="server" style="display:none" ScrollBars="Horizontal" CssClass="ModalPopupPanel">

<div style="float:right;">

<asp:LinkButton ID="lnkClose" runat="server">Close</asp:LinkButton>

</div>

<asp:Label ID="lblDescription" runat="server" Text='<%# Eval("Description") %>' /><br /><br />

Teams Sent:  <asp:Label ID="lblTeamsSent" runat="server" Text='<%# Eval("TeamsSent") %>' /><br />

Volunteers: <asp:Label ID="lblPeopleVolunteered" runat="server" Text='<%# Eval("PeopleVolunteered") %>' />

</asp:Panel>

<ajax:ModalPopupExtender ID="extProject" runat="server" TargetControlID="btnTrigger" PopupControlID="pnlProject" DropShadow="true" BackgroundCssClass="ModalPopupBackground" CancelControlID="lnkClose" /><

PopupControlID="pnlProject" DropShadow="true" BackgroundCssClass="ModalPopupBackground" CancelControlID="lnkClose" /><<!-- Do not remove; triggers the modal popup -->

<asp:Button ID="btnTrigger" runat="server" Style="display: none" />

</ItemTemplate></asp:TemplateField>

</Columns>

</asp:GridView>

The modal popup extender maps to a button that is hidden.  Why do I do that?  In the Selected index changed event handler, I did this:

</asp:GridView>

The modal popup extender maps to a button that is hidden.  Why do I do that?  In the Selected index changed event handler, I did this:

The modal popup extender maps to a button that is hidden.  Why do I do that?  In the Selected index changed event handler, I did this:
void gvwProjects_SelectedIndexChanged(object sender, EventArgs e)

{

GridViewRow row = ((GridView)sender).SelectedRow;

if (row == null) return;

ModalPopupExtender extender = row.FindControl("extProject") as ModalPopupExtender;

if (extender != null) extender.Show();

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

if (extender != null) extender.Show();

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

ModalPopupExtender extender = row.FindControl("extProject") as ModalPopupExtender;

if (extender != null) extender.Show();

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

if (extender != null) extender.Show();

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

if (row == null) return;

ModalPopupExtender extender = row.FindControl("extProject") as ModalPopupExtender;

if (extender != null) extender.Show();

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

if (extender != null) extender.Show();

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

ModalPopupExtender extender = row.FindControl("extProject") as ModalPopupExtender;

if (extender != null) extender.Show();

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

if (extender != null) extender.Show();

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

}

This was a web site project for our work down in Louisiana, that I was working on for my church.  Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project.  Through this, you can programmatically popup an modal window.

The CSS class that I use for the background is also defined as this:

.ModalPopupBackground

{

background-color:#162C66;

opacity:.9;

filter: alpha(opacity=90);

}

I hope you may find use in this.

}

I hope you may find use in this.

filter: alpha(opacity=90);

}

I hope you may find use in this.

}

I hope you may find use in this.

opacity:.9;

filter: alpha(opacity=90);

}

I hope you may find use in this.

}

I hope you may find use in this.

filter: alpha(opacity=90);

}

I hope you may find use in this.

}

I hope you may find use in this.

Published Saturday, February 17, 2007 8:44 PM by bmains
Filed under: ,

Comments

# re: Modal Popup in Gridview

Wednesday, February 28, 2007 7:47 AM by bmains

I apologize for this post, as it somehow got screwed up.  I even fixed the problem, and when I posted it, it happened again.  So, I'm going to have to leave it that way.

Brian

# re: Modal Popup in Gridview

Thursday, May 24, 2007 1:49 PM by nkmajeti

Hi.

This option is exactly what I would like to implement in one of my projects. I am not able to understand the code clearly from the blog. Will you be able to email me the code?

my email address is nandu.net@gmail.com

Thanks,

Nandu

# re: Modal Popup in Gridview

Saturday, September 29, 2007 7:28 PM by TearIzUp

Excellent Post. My compliments to the author.

--------------------------------SIG----------------------------------

<a href="salvia2.psychepisode.info/">Buy Salvia Divinorum</a>

<a href="salvia2.psychepisode.info/">Salvia Divinorum</a>

# re: Modal Popup in Gridview

Wednesday, November 07, 2007 4:26 PM by votaslifill

Stress is taking a toll on people -- contributing to health problems... <a href=http://hair-loss-propecia-treatment.worldbookforum.info>m

en health problem</a> <a href=http://levitra-dosage.trainingforumonline.info>weight loss plan</a>...

# re: Modal Popup in Gridview

Friday, January 11, 2008 1:38 PM by Jason Wilson

Why did you put the extender in the gridview.  I'm doing the same thing with it out and it works well and there is no need to use FIndControl.

# re: Modal Popup in Gridview

Tuesday, February 19, 2008 5:00 AM by Metaller

# re: Modal Popup in Gridview

Friday, February 29, 2008 9:30 PM by zxevil135

JSXIxH r u crazzy? I told u! I can't read!

# re: Modal Popup in Gridview

Saturday, March 01, 2008 3:41 PM by zxevil136

WOjWq3 r u crazzy? I told u! I can't read!

# re: Modal Popup in Gridview

Thursday, March 06, 2008 5:16 PM by zxevil134

q4zaSJ r u crazzy? I told u! I can't read, man!

# re: Modal Popup in Gridview

Thursday, March 06, 2008 8:18 PM by zxevil141

ykJyje r u crazzy? I told u! I can't read!

# re: Modal Popup in Gridview

Friday, March 07, 2008 2:06 PM by zxevil150

UpkW7f r u crazzy? I told u! I can't read!

# re: Modal Popup in Gridview

Friday, March 07, 2008 5:06 PM by zxevil151

ZRVRWs r u crazzy? I told u! I can't read!

# re: Modal Popup in Gridview

Friday, March 07, 2008 8:21 PM by zxevil152

zJLirU r u crazzy? I told u! I can't read!

The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.