نوشته شده توسط
C#_web
منم همین مشکل mehdi58 را دارم . البته در سی شارپ به asp.net .
میخوام موقع زدن دکمه حذف ، برای حذف یک رکورد ابتدا از کاربر سوال بشه که آیا تمایل به حذف داری؟ اگر ok زد ، اون رکورد حذف بشه در غیر اینصورت کاری نکنه.
میشه راهنمایی کنین چه کار کنم؟؟
اگر از گرید ویو استفاده میکنی اول یک ستون جدید اضافه کن و یک Link button در آن قرار بده و Command name را مساوی delete قرار بده سپس در Gridview_databound کد زیر را قرار دهید :
If e.Row.RowType = DataControlRowType.DataRow Then
' make sure we can find the control first
If e.Row.FindControl("LinkButton2") IsNot Nothing Then
' cast it to a LinkButton and set the client script
CType(e.Row.FindControl("LinkButton2"), LinkButton).OnClientClick = _
"return confirm('آیا از حذف شاخص مطمئن هستید ؟ ');"
End If
End If
و در سی شارپ :
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");
l.Attributes.Add("onclick", "javascript:return " +
"confirm('Are you sure you want to delete this record " +
DataBinder.Eval(e.Row.DataItem, "CategoryID") + "')");
}
}
البته من خودم VB کارم اگر اطلاعات بیشتری برای C# میخوای اینو ببین :
http://www.codeproject.com/aspnet/Gr...firmDelete.asp