<script type="text/javascript"> //Confirmation box sample function ConfirmationBox() { var result = confirm("Are you sure you want to Delete?"); if (result == true) { return true; } else { var lbl = document.getElementById('Resultlbl'); lbl.innerHTML = ""; return false; } } <pre lang="xml"><asp:DataList ID="DataList1" runat="server" > <ItemTemplate> <table cellpadding="15" cellspacing="15" width="700px"> <tr> <td class="Subheadfont" width="80%"><%# Eval("ProjectName")%></td> <td width="10%"><a href="Edit_Project.aspx?Proid=<%# Eval("ProjectID") %>">Edit</a></td><td width="10%"><a href="List Of Projects.aspx?Proid=<%#Eval("ProjectID")%>"> <asp:Button ID="BtnDelete" runat="server" OnClientClick="return ConfirmationBox()" onclick="btnSubmit_Click" Text="Delete"></asp:Button></a></td> </tr> <%-- <tr><td><a href="FullProjectDetails.aspx?Proid=<%# Eval("ProjectID") %>"> <img src="Admin/ProImages/<%# Eval("Image1") %>" width="180px" alt="" height="150px" /></a> </td> </tr>--%> </table> </ItemTemplate> </asp:DataList>
public partial class ListAllProjects : System.Web.UI.Page { Admin Objadmin = new Admin(); int proid; protected void Page_Load(object sender, EventArgs e) { BindProjects(); } public void BindProjects() { DataSet ds = new DataSet(); ds = Objadmin.View_All_Projects(); DataList1.DataSource = ds; DataList1.DataBind(); } protected void btnSubmit_Click(object sender, EventArgs e) { proid = Convert.ToInt32(Request.QueryString["Proid"]); if (proid > 0) { // Delete Record in Database String check = Objadmin.Delete_Project(proid); if (check == "yes") { Resultlbl.Visible = true; Resultlbl.Text = "Project Deleted Successfully!"; BindProjects(); } else { Resultlbl.Visible = true; Resultlbl.Text = "Project Not Deleted!"; } } else { BindProjects(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)