title: Disabling textbox upon selecting specific value in drop down of gridview
body: <p>i have a gridview and each row has Drop down list,Containing VALID (1), INVALID (0)</p>
  
  <p>i want if user select Invalid from drop down then it should disable text box given in form, txtComplainant.</p>
  
  <p>i tried putting TxtboxComplainant.Visible = false; upon SelectedIndexChange Event but doesn't work.</p>
  
  <p>Code:</p>
  
  <pre><code>protected void ddlIsComplaint_SelectedIndexChanged(object sender, EventArgs e) 
      {
          DropDownList ddl = (DropDownList)sender;
          GridViewRow row = (GridViewRow)ddl.NamingContainer;
          int RowIndex = Convert.ToInt32(row.RowIndex);
          //lblSelectionMessage.InnerText = RowIndex.ToString();
  
          foreach(GridViewRow rw in GridViewSmsComplaints.Rows)
          {
              if(rw.RowIndex != RowIndex)
              {
                  rw.Enabled = false;
              }
          }
              if (ddl.SelectedValue == "0") 
              {
                  txtComplainant.Visible = false;
              }
       }
  </code></pre>
  
  <p>Aspx:</p>
  
  <pre><code>&lt;asp:GridView ID="GridViewSmsComplaints" AllowPaging="True" PageSize="5" runat="server" AutoGenerateColumns="False" CssClass="mGrid" BorderColor="#333333"  Width="650px" OnRowDataBound="GridViewSmsComplaints_RowDataBound" OnPageIndexChanging="GridViewSmsComplaints_PageIndexChanging" &gt;
                 &lt;Columns&gt;
                      &lt;asp:BoundField HeaderText="Sms ID" DataField="ID" /&gt; 
                      &lt;asp:BoundField HeaderText="Recieving Date" DataField="RecievingDate" /&gt;  
                      &lt;%--&lt;asp:BoundField HeaderText="ToMobileNo" DataField="ToMobileNo" /&gt;  --%&gt;
                      &lt;asp:BoundField HeaderText="Incoming No" DataField="FromMobileNo" /&gt; 
                      &lt;asp:BoundField HeaderText="Complaint" DataField="Message" &gt;   
                       &lt;ItemStyle Wrap="True" /&gt;
                      &lt;/asp:BoundField&gt;
                      &lt;asp:TemplateField HeaderText="Is Valid?"&gt;
                       &lt;ItemTemplate&gt;
                         &lt;%--&lt;asp:CheckBox ID="ckboxIsComplaint"  runat="server" /&gt;--%&gt;
                         &lt;asp:DropDownList ID="ddlIsComplaint" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlIsComplaint_SelectedIndexChanged"&gt;
                          &lt;asp:ListItem Text="-Select-" Value="-1"&gt;&lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="Invalid" Value="0"&gt;&lt;/asp:ListItem&gt;
                          &lt;asp:ListItem Text="Valid" Value="1"&gt;&lt;/asp:ListItem&gt;
                         &lt;/asp:DropDownList&gt;
  
                       &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                 &lt;/Columns&gt;
              &lt;/asp:GridView&gt; 
  
  &lt;asp:TextBox ID="txtComplainant" runat="server" CssClass="textField_width"&gt;&lt;/asp:TextBox&gt;
  </code></pre>