2013-04-23 79 views
0

我有一個GridView控件內的複選框和文本框。對於複選框,沒有CommandName屬性可用於在GridView的RowCommand事件中使用它。每當複選框選中狀態改變時,我需要在gridview之外啓用一些按鈕。有沒有其他方法可以實現這一目標?RowCommand事件替代GridView中的複選框

下面的代碼片段,我都試過,但按鈕沒有得到啓用,

<asp:CheckBox ID="chkFee" runat="server" AutoPostBack="true" OnCheckedChanged="chkFee_Changed" /> 

      protected void chkFee_Changed(object sender, EventArgs e) 
      { 
       BtnCalculate.Enabled = true; 
       btnSubmit.Enabled = false;     
      } 
In Javascript is called before the this Checkedchanged event, 
function Calc(obj) { 

      var BtnCalculate = document.getElementById("<%= BtnCalculate.ClientID %>"); 
       BtnCalculate.disabled = true; 
}  

回答

0

這是aspx文件..............

<asp:CheckBox ID="chkBook" runat="server" 
    AutoPostBack="true" OnCheckedChanged="chkBook_Changed" /> 

這是CS文件..........

protected void chkAssignAll_CheckedChanged(object sender, EventArgs e) 
      { 

       GridViewRow gr = (GridViewRow) ((DataControlFieldCell) ((CheckBox) sender).Parent).Parent; 
       CheckBox chk1 = (CheckBox) gr.FindControl("chkAssignSun"); 
       CheckBox chk2 = (CheckBox) gr.FindControl("chkAssignMon"); 

       chk1.Checked = ((CheckBox) sender).Checked; 
       chk2.Checked = ((CheckBox)sender).Checked;      
      } 

試試這個代碼.............

+0

我已經diabled從Javascript的按鈕,我只是想使其在事件的CheckedChanged,我也會做同樣的,但按鈕依然是禁用。 – MahaSwetha 2013-04-23 09:38:23

相關問題