GridView中有两个模板列,一个checkbox列,一个TextBox列,如何用js控制,在checkbox列选择时才可以输入文本?
当checkbox列没选择时,将文本中的内容清空。

解决方案 »

  1.   

    可以先把textbox列的textbox控件设为只读属性,然后在checkbox的onchange事件中判断是否选中,选中的话,将此对应的textbox只读属性改为false至于如何找到checkbox和对应的textbox以及如何后台响应checkbox的change事件这些CSDN上的贴子已经有无数了,找一下看看就好了
      

  2.   

    在GridView的RowDataBound事件里写
      

  3.   

    checkbox列<itemtemplate>
    <input type='CheckBox" onclick="GoChangeTextBox(this);">
    </itemtemplate>
    function GoChangeTextBox(obj)
    {
     var txt = obj.parentElement.nextSibling.firstChild;
     txt.disabled = !obj.checked;
     if(!obj.checked) txt.value = "";
    }
      

  4.   

    模板列 
    在checkbox的onchange事件中: GridViewRow editRow = (GridViewRow)(((Control)sender).Parent.Parent);
                   TextBox txtMaster = (TextBox)(editRow.FindControl("txtMaster"));
                   txtMaster.Enabled = !(txtMaster.Enabled);