Reputation: 91
I am working on visual studio 2010 with SQL Server Management studio.
I have made a button for deleting selected rows from the table.
<asp:Button ID="btnDeleteSelectedMessages" runat="server"
Text="Verwijderen" Enabled="false"
OnClick="btnDeleteSelectedMessages_Click" />
It works perfectly for the first time when I run the page first time.
then after the button can't be clicked second time.
the code on button click event is like this.
protected void btnDeleteSelectedMessages_Click(object sender, EventArgs e)
{
if (currentGridView == null)
setCurrentGridView();
//controleer voor elke rij welke checkbox is geselecteerd
foreach (GridViewRow row in currentGridView.Rows)
{
var cb = (HtmlInputCheckBox)row.FindControl("chkPaid");
Guid messageID = (Guid)currentGridView.DataKeys[row.DataItemIndex].Value;
//als de checkbox is geselecteerd het bericht verwijderen
if (cb != null && cb.Checked)
{
if (currentGridView.ID.Equals("Messages"))
b.BussinesMessageReceiver.DeleteMessageReceiver(messageID, MessageBoxPerson);
else if (currentGridView.ID.Equals("MessagesSent"))
b.BussinesMessage.DeleteMessageSender(messageID);
else //MessagesDeleted
b.BussinesMessage.DeleteMessage(messageID, (Page.Server.MapPath("~/Upload/") + messageID));
continue;
}
}
btnDeleteSelectedMessages.Enabled = false;
selectLocation.Visible = false;
clearSelectedMessageSession();
//Update the GridView
BindGridView();
}
Can any one help me?
Upvotes: 0
Views: 119
Reputation: 39265
With this code:
btnDeleteSelectedMessages.Enabled = false;
you DISable the button. Do you maybe enable that button in the Page_Load? The Button_Click handler fires after the Load, so you end up with a disabled button.
So you need to remove that line (why did you put it in there?)
Upvotes: 3
Reputation: 603
Button must to Enable (Enable="true") to work,
<asp:Button ID="btnDeleteSelectedMessages" runat="server" Text= "Verwijderen" Enabled="true" OnClick="btnDeleteSelectedMessages_Click" />
Upvotes: 1