Hello.
if someone could help on this problem please..
I have a griedView that renders books from a database.
In each line a DELETE/EDIT button is rendered.
I want when the user clicks the EDIT button, the CANCEL,UPDATE buttoms to appear and the EDIT buttton to become disabled..
I though of using the onclick event for the edit button along with the griedView Row for getting the appropriate button based on the row..
Set the Edit button's Enable property to false and the Visibility of the Cancel and Edit buttons to true.
However, it seems I can not change the properties even for the Edit button i get from the event handler..
I am missing something..
Here is the code...
protected void EditButton_Click(object sender, EventArgs e)
{
Button Sender = (Button)sender;
Sender.Text = "??"; //THIS CHANGE IS NOT APPLIED!!
//Button Sender = (Button)sender;
//GridViewRow grdRow = (GridViewRow)Sender.Parent.Parent;
//Button btn = (Button)grdBooks.Rows[grdRow.RowIndex].Cells[1].FindControl("CancelButton");
}
<asp:GridView
id="grdBooks"
DataSourceID="srcBooks"
DataKeyNames="Product_ID"
AutoGenerateColumns="false"
CssClass="products"
GridLines="none"
Runat="server" OnRowCreated="grdBooks_RowCreated">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button CausesValidation="false" ID="DeleteButton" CommandName="Delete" runat="server" Text="Delete" />
<asp:Button CausesValidation="false" ID="EditButton" CommandName="Edit" runat="server" Text="Edit" OnClick="EditButton_Click" />
<asp:Button CausesValidation="false" ID="CancelButton" Enabled="false" Visible="true" CommandName="Cancel" runat="server" Text="Cancel" />
<asp:Button CausesValidation="false" ID="UpdateButton" Enabled="false" Visible="true" CommandName="Update" runat="server" Text="Update" />
</ItemTemplate>
</asp:TemplateField>
<%-- <asp:CommandField ButtonType="Button" ShowEditButton="true"/>--%>
<asp:BoundField
DataField="ISBN"
ReadOnly="true"
HeaderText="ISBN" />
<asp:BoundField
DataField="Title"
ReadOnly="true"
HeaderText="Title" />
<asp:BoundField
DataField="First_Name"
ReadOnly="true"
HeaderText="First Name" />
<asp:BoundField
DataField="Last_Name"
ReadOnly="true"
HeaderText="Last Name" />
<asp:BoundField
DataField="Price"
HeaderText="Price" />
<asp:BoundField
DataField="Quantity"
HeaderText="Quantity" />
</Columns>
</asp:GridView>