title: Edit value in DataRowView
body: <p>I'm using VS 2008 at the moment for my development (ASP.NET C#).</p>
  
  <p>Currently I'm facing some problem with GridView:</p>
  
  <p>I bind data to the GridView DataSource using a DataSet (query from database), I then have a checkbox which allow user to hide or display the column using the following method :</p>
  
  <pre><code>    if (chkPhone.Checked == true) { strSQL += ", recruit_website as 'Website'"; }
  </code></pre>
  
  <p>Okay now the problem I facing is that, how do I make this specific column rows to wrap with anchor tag? So that user can go to the respective website directly though the GridView.</p>
  
  <p>So the first approach I use was to use the 'RowDataBound' event and do something like :</p>
  
  <pre><code>    e.Row.Cells[7].Text = "&lt;a href='" + e.Row.Cells[7].Text + '"&gt;Click Me&lt;/a&gt;";
  </code></pre>
  
  <p>But then the problem comes, IF the user choose not to display this column, the column index will be different. (There are more options for user to hide the column so -1 in index doesn't make sense)</p>
  
  <p>Well so this approach fails, I tried using another approach which is using the DataRowView in the 'RowDataBound' event :</p>
  
  <pre><code>    if (e.Row.RowType == DataControlRowType.DataRow)
      {
          DataRowView rowView = (DataRowView)e.Row.DataItem;
  
          rowView["Website"] = "something"; //something to deal with here
      }
  </code></pre>
  
  <p>Using this method I can get the value from the GridView using the column name, but I can't set the value.</p>
  
  <p>So what's the best solution for this situation?</p>