グリッドビューの分離コードで Container.DataItem を変更できるかどうか疑問に思っています。つまり、条件に応じて Dataitem を「SellingPaymentMethod」から「DeliveryPaymentmethod」に変更したい場合です。
販売と配送の両方の情報を取得するために、同じストアド プロシージャを使用しています。したがって、販売の場合は SellingPaymentmethod である必要があり、そうでない場合は DeliveryPaymentmethod である必要があります。これは、C# を使用した ASP.Net にあります。
<asp:TemplateField ItemStyle-Width="70" ItemStyle-HorizontalAlign="Center">
    <ItemTemplate>
      <asp:Label ID="lblSellingPaymentMethod" runat="server"
         Text='<%#DataBinder.Eval(Container.DataItem,"SellingPaymentMethod") %>'>
      </asp:Label>
    </ItemTemplate>
 </asp:TemplateField>
if(Condition1 = "Selling")
{
    use sellingpaymentmethod container
}
else
{
    use deliverypaymentmethod
}
編集:
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;
        Label lblBalance = e.Row.FindControl("lblTotalSold") as Label;
        Label lblBalanceCollected = e.Row.FindControl("lblTotalCollected") as Label;
        if (lblTypeofDay.Text == "Selling")
        {
            lblPaymentMethod.Text = dtrCurrentRow["SellingPaymentMethod"].ToString();
        }
        else if (lblTypeofDay.Text == "Delivery")
        {
            lblPaymentMethod.Text = dtrCurrentRow["DeliveryPaymentmethod"].ToString();
        }
     }
これが私があなたのコードを使用した方法です。また、すべての行の支払い方法列に最後の行の値が含まれている理由がわかりません。
そして、btnSubmit_OnClick関数にデータバインディングコードがあります
DataView myDataView = new DataView();
myDataView = dsnew.Tables[0].DefaultView;
grdDetail.DataSource = myDataView;
grdDetail.DataBind();