Hai
Try like this,i think u delete data form table and rebind dropdown,
Delete from Department where Dept <> "Admin"
if (DropDownList1.Text == "Administrator")
{
}
else
{
DropDownList1.Items.Remove(DropDownList1.SelectedItem);
con.Open();
string query ="Delete from Role1 Where Role_Name ='" + DropDownList1.Text +"'";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
}
I don't know what u exact needs,in dropdownbox u remove select item only,but in Role1 table u remove all data excluding Administrator.
How to bind data in dropdownbox ? in design time u add items or dynamically bind data form table.If u bind data from table dynamically to dropdownbox then try below code
if (DropDownList1.Text == "Administrator")
{
}
else
{
con.Open();
string query ="Delete from Role1 Where Role_Name ='" + DropDownList1.Text +"'";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
Binddropdown();
}
I think how u know to bind data to dropdownbox dynamically in Bind dropdown function u write code to bind data like dropdownlist1.ds; dropdownlist1.bind ect...
Regards
Aravind