By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,247 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,247 IT Pros & Developers. It's quick & easy.

Display Ok/Cancel Message in gridview template(check Box).

P: 26
Hi,
I am using Grid View Template field(Check Box) for delete a row, but i need a message box(OK/Cancle) should display before deleting the row.My C# Code like this for deleting the row when we click on check box of grid view.

protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
{

CheckBox chk = (CheckBox)sender;
GridViewRow row = (GridViewRow)chk.NamingContainer;
if (chk.Checked == true)
{
string str = Convert.ToString(row.Cells[3].Text).Trim();
string str1 = Convert.ToString(row.Cells[4].Text).Trim();
string str2 = Convert.ToString(row.Cells[6].Text).Trim();
string StrSql = "Update AppointmentMaster set status='" + 0 + "' where LastName='" + str + "' and FirstName='" + str1 + "' and dob='" + str2 + "'";
int intResult = ObjDat.ExecuteSQL(StrSql);


string Appdel = "select * from AppointmentMaster where Status='"+1+"'";

DataSet ds = objDAL.GetInfo(Appdel);

GridView1.DataSource = ds;
GridView1.DataBind();

}

}

And my Js function for displaying message like this

function MsgOkCancel()
{

var fRet;
fRet = confirm('Are you sure?');
alert(fRet);

if(fRet==true)
{
;
//alert("done")
}
if(fRet==false)
{
//alert("not done")
}


}

But i am not able to combine these two that is When i select the Check Box in Grid View the js function shoud call. Please help me to solve this problem.
Aug 11 '07 #1
Share this Question
Share on Google+
3 Replies


kenobewan
Expert 2.5K+
P: 4,871
Have you tried attributes.add()?
Aug 11 '07 #2

P: 26
yes i have tryed attribute .add like this

controlname.attribute.add("Name of JS function") but it is not working
Aug 12 '07 #3

kenobewan
Expert 2.5K+
P: 4,871
Usually the syntax is attribute.add("event","function name"). HTH.
Aug 12 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.