Hello Masroor,
If I understand your question correctly then please refer to
this[
^] article. It shows how to do INSERT/UPDATE using a gridview.
Now lets assume that you want to confirm the delete operation by first displaying the name, followed by another confirm showing the name and the id. In that case you can hook up following JavaScript function.
function confirmDelete(strName, strId) {
var r = confirm("Will delete " + strName);
if (r == true) {
r = confirm("Will delete record having id " + strId + " and name " + strName);
if (r == true) return true;
}
return false;
}
The javascript wiring will be done in
RowDataBound
event of the gridview. So do remove the onClientClick code from the aspx file shown in above article. The wiring up code in your code behind will be something like one shown below.
protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e ) {
try {
if (e.Row.RowType == DataControlRowType.DataRow) {
DataRowView drEachRow = (DataRowView) e.Row.DataItem;
LinkButton lbBind= (LinkButton )e.Row.FindControl("lnkRemove");
lbBind.Attributes.Add("onclick", "javascript:return confirmDelete('" + DataBinder.Eval(e.row.DataItem, "ContactName") +
"', '" + DataBinder.Eval(e.row.DataItem, "CustomerID") + "');");
}
}
catch(Exception objExp) {
}
}
Regards,