title: How to Check the CheckBox in a GridView based on Condition?
body: <p>i am a beginner. I have four textbox fields for ItemName, ItemDescription, Length and Quantity.
  One radiobuttonlist and its listitems are FixedLength and Random Length.
  One button field called Submit and one gridview.</p>
  
  <p>In the GridView I have 4 bound columns and 1 template column such as ItemName, ItemDescription, Length, Quantity and IsFixed_f(flag field). I have added one checkbox in the GridView's Template column for the IsFixed_f field.</p>
  
  <p>After entering all textbox fields, I have to select either one listitem in the radiobuttonlist(FixedLength or RandomLength). After completing these things. If I enter the Submit button, all the values in the textbox to be displayed under the GridView's corresponding column name and checkbox to be checked if FixedLength listitem is selected otherwise the checkbox.checked should be false. How to do this?</p>
  
  <p>In the Button Click event, i have used like this</p>
  
  <pre><code>        DataRow DR = null;
          DR = datatable.NewRow();
          DR["ItemName"] = DSItemName.Text.Trim();
          DR["Description"] = txtItemDescription.Text.Trim();
          DR["Length"] = txtLength.Text.Trim();
          DR["Quantity"] = txtQuantity.Text.Trim();
          datatable.Rows.Add(DR);
          GridView.DataSource = datatable;
          GridView.DataBind();
  </code></pre>
  
  <p>But I dont know How to Check the CheckBox and Displays it in the GridView. Please give suggestions.
  If I use the following code, It displays the text "true" with the CheckBox in the GridView.</p>
  
  <pre><code>        foreach (GridViewRow GVR in gridview.Rows)
          {
              CheckBox cb = (CheckBox)GVR.FindControl("cbIsFixed_f");
  
              if (cb != null &amp;&amp; radiobuttonlist.SelectedItem.Value == "Fixed Length")
              {
                  cb.Checked = true;
              }
              else
              {
                  cb.Checked = false;
              }
              DR["IsFixed_f"] = cb.Checked;
          }
  </code></pre>