I have a grid in which i have 7 columns where all the checkboxes are disabled. How do I disable the delete button?
In the diagram below, if all the checkboxes in the Cancel SO Line Item column are disabled then the DEL button should be disabled
.Aspx File
<asp:TemplateField HeaderText="Cancel SO Line Item">
<ItemTemplate>
<asp:checkbox ID="cbSOCan" runat="server" ViewStateMode="Enabled" EnableViewState="true"></asp:checkbox>
</ItemTemplate>
<asp:LinkButton CssClass="btn btn-primary" ID="btnCancelItem" runat="server" CausesValidation="False"OnClientClick="return Confirmationbox();"> Cancel Item</asp:LinkButton>
<asp:HiddenField id="hdnval" value=0 runat="server"/>
C# code
protected void btnCancelItem_Click(object sender, EventArgs e)
{
foreach (GridViewRow gvrow in gvPOItems.Rows) {
CheckBox chkdelte = (CheckBox)gvrow.FindControl("cbSOCan");
HiddenField hdnval = (HiddenField)gvrow.FindControl("hdnval");
if (chkdelte.Checked) {
// gvAdditionalArea.Rows(rowIndex).Cells(0).Text()
Int32 ItemNumber = Convert.ToInt32(gvrow.Cells(0).Text());
Queries.CancelSOlineItem(ItemNumber, txtPONumber.Text);
gvrow.Cells(7).Text() = "Cancelled";
chkdelte.Checked = false;
chkdelte.Enabled = false;
hdnval.Value = 1;
}
}
protected void Page_Load(object sender, EventArgs e)
{
{if (!IsPostBack)
int rowcount = 0;
foreach (GridViewRow gvrow in gvPOItems.Rows) {
HiddenField hdnval = (HiddenField)gvrow.FindControl("hdnval");
if ((hdnval.Value == 1)) {
rowcount = rowcount + 1;
}
}
if ((gvPOItems.Rows.Count == rowcount)) {
btnCancelItem.Visible = false;
}
}
}
Aucun commentaire:
Enregistrer un commentaire