I have created a template column for Select All in datagrid to delete records for a particular page when Select All checkbox is checked.
But the entire records of the table are deleted when the Select All checkbox is checked and Delete button is clicked.
What could be the solution... I require code to delete the records on button click.
Loading
Sandhya BhosalePosted Oct 19, 2006, 2:38 AM
Actually I have written the code for delete button click as follows:
protected
void btndelete_Click(object sender, EventArgs e){
CheckBox
SelectAll; foreach (DataGridItem dgi in MyDataGrid.Items){
int topicid; string strSQL;SelectAll = dgi.FindControl(
"chkSelect"); // chkSelect is the Item template of checkbox. if (SelectAll.Checked){
topicid =
Convert.ToInt32(MyDataGrid.DataKeys(dgi.ItemIndex)).ToString();strSQL =
"delete from Admin_Add_Newsletter_Topic where Topic_Id=" & topicid & ";";
SqlConnection con = new SqlConnection(ConnectionString); SqlCommand cmd = new SqlCommand(strSQL, con);cmd.CommandType =
CommandType.Text;con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
However, it does not work.
Also, I have not converted topic id to template column. Can that be a problem???
pratap reddyPosted Oct 18, 2006, 7:32 AM
clearvalue();
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
blnReturn = xmlDoc.load("/Corporate_Departments/Human_Resources/HR_Support_Center/eGO_Forms/includes/ldap_Query.asp?Filter=" + strFilter);
if (blnReturn)
{
nodes=xmlDoc.documentElement.childNodes;
for (iCount=0; iCount < nodes.length;iCount++)
{
document.frmSubmit.item("txtName").value = nodes.item(iCount).childNodes.item(0).text;
document.frmSubmit.item("txtMgrName").value = nodes.item(iCount).childNodes.item(5).text;
document.frmSubmit.item("txtMgrPH").value = nodes.item(iCount).childNodes.item(9).text;
document.frmSubmit.item("txtManagerEmpID").value = nodes.item(iCount).childNodes.item(16).text;
}
}
else
{
alert("User Information not available in eGO, this might be due to invalid employee id or the User left Best Buy. Please check the number and try again.");
document.frmSubmit.item("txtEmpID").focus();
document.frmSubmit.item("txtEmpID").value = "";
document.frmSubmit.item("txtName").value = "";
document.frmSubmit.item("txtMgrName").value = "";
document.frmSubmit.item("txtMgrPH").value = "";
document.frmSubmit.item("txtManagerEmpID").value = "";
}
}