Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make a pop-up box inside a GridView

Status
Not open for further replies.

MaryNET

Programmer
Jan 6, 2007
33
0
0
US
Inside a GridView, I would like to display a
pop-up box when this Delete button is clicked:

<asp:CommandField ShowDeleteButton="True" />

Can this be done? Thanks
 
You will have to add an onclick attribute to the button which will call a javascript function that will display an alert() or confirm()
 
Can that be done using the
<asp:CommandField ShowDeleteButton="True" />
type "button"?

I would like to use a regular button instead, like in
a asp:TemplateField for this, but can't figure out how to do it, or even if it can be done;

I would to also make this asp:TemplateField field:

<asp:CommandField ShowEditButton="True" ButtonType="Link" />



 
Using the Template Column approach....

Look up information on the OnRowDatabound event, using FindCOntrol to get a hook on the button, then as jbenson said, button.attributes.add("onclick", "your javascript code here");
 
This worked:

<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton CommandName="Delete" OnClientClick="return confirm('Are you sureyou want to delete this record?');" ID="btnDelete" Text="Delete" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton CommandName="Edit" ID="btnEdit" Text="Edit" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

But the Edit button doesn't automatically hide, like the other did.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top