Row Databound issue when changing Container.DataItem value in a gridview
<p>I am using a gridview to display on a buttonClick in asp.net using c#.</p>

<pre><code> DataSet dsnew  = new businessLogic.Biz().getData();
 if (dsnew != null &amp;&amp; dsnew.Tables[0].Rows.Count &gt; 0)
 {
     DataView myDataView = new DataView();
     myDataView = dsnew.Tables[0].DefaultView;
     grdDetail.DataSource = myDataView;
     grdDetail.DataBind();
 }
</code></pre>

<p>and on a rowDataBound, depending on the condition, i want to change the dataitem container value. I am doing it in the following way but the issue is that all the rows have the paymentmethod of the last row in the dataset.  </p>

<pre><code>&lt;asp:TemplateField ItemStyle-Width="70" ItemStyle-HorizontalAlign="Center"&gt;
   &lt;ItemTemplate&gt;
       &lt;asp:Label ID="lblPaymentMethod" runat="server" Text='&lt;%#DataBinder.Eval(Container.DataItem,"SellingPaymentMethod") %&gt;'&gt;&lt;/asp:Label&gt;
   &lt;/ItemTemplate&gt;
&lt;/asp:TemplateField&gt;


protected void grdDetail_RowDataBound(object sender, GridViewRowEventArgs e)
{

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        return;
    }

    foreach (DataRow dtrCurrentRow in (((System.Data.DataView)grdDetail.DataSource)).Table.Rows)
    {
        //DataRow row = (DataRow)e.Row.DataItem;
        Label lblPaymentMethod = e.Row.FindControl("lblPaymentMethod") as Label;

        if (Condition1))
        {
            lblPaymentMethod.Text = dtrCurrentRow["SellingPaymentMethod"].ToString();
        }
        else if (Condition 2)
        {
            lblPaymentMethod.Text = dtrCurrentRow["DeliveryPaymentmethod"].ToString();
        }         

    }    
</code></pre>
