如何通过javascript / C#禁用网格ASP.NET中的列中的所有复选框时禁用按钮? [英] How to disable a button when all the checkboxes in are disabled of a column in grid ASP.NET by javascript/C# ?

查看:63
本文介绍了如何通过javascript / C#禁用网格ASP.NET中的列中的所有复选框时禁用按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格,其中我有7列,其中所有复选框都被禁用。如何禁用删除按钮?



在下图中,如果取消SO行项目列中的所有复选框都被禁用,则应禁用DEL按钮。



我尝试过:



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.

What I have tried:

<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



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;
}
}
}

推荐答案

http://www.programmingposts.com/2016/05/check-uncheck-all-checkboxes-in-table -jquery.html [ ^ ]



通过以上链接,在代码中进行必要的小改动,例如。



http://www.programmingposts.com/2016/05/check-uncheck-all-checkboxes-in-table-jquery.html[^]

Go through the above link, make small necessary changes in code like.

function chkRowClicked() {
             var unChkCount = 0, ChkCount = 0;
             ChkCount =


' 。clsChkRow:checkbox:checked' )长度。
unChkCount =
('.clsChkRow:checkbox:checked').length; unChkCount =


' 。clsChkRow:checkbox:not( :选中)')长度;
if (ChkCount == 0 ){
('.clsChkRow:checkbox:not(:checked)').length; if (ChkCount == 0) {


这篇关于如何通过javascript / C#禁用网格ASP.NET中的列中的所有复选框时禁用按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆