如何使用asp.net c中的Conformation框传递Eval值# [英] How to pass Eval values using Conformation box in asp.net c#
本文介绍了如何使用asp.net c中的Conformation框传递Eval值#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我列出了所有项目名称以及datalist上的编辑和删除选项。我使用了删除按钮的构造框。它工作。但是当我点击是然后项目ID不通过查询字符串传递...我需要通过该项目ID从数据库中删除特定项目...我怎么能通过当用户在构造框上单击是时该ID?
ASPX文件:
I am list all the project name with edit and delete option on datalist. I am used conformation box for delete button.Its worked.But when i clicked yes then the Project id is not passed via query string... I need to delete the particular project from database through that project id... How can i pass that id when user clicks yes on conformation box?
ASPX FILE:
<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>
ASPX.CS文件:
ASPX.CS File:
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();
}
}
}
推荐答案
在Edit_Project.aspx或List Of Projects.aspx上您可以通过查询字符串轻松获取ProID并编辑/删除它。
On the Edit_Project.aspx or List Of Projects.aspx you can easily get the ProID via querystring and Edit/delete it.
这篇关于如何使用asp.net c中的Conformation框传递Eval值#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文