【问题标题】:Gridview doesn't update in asp.netGridview 在 asp.net 中不更新
【发布时间】:2012-05-14 16:14:18
【问题描述】:

当我从GridView 中删除一行时,它不会更新。 我也看过这里

Gridview doesnt update after the delete command

没有任何解决办法。

这是我的一些代码

private void SepettenOgeSil(int p)
{
    SqlDataSource4.DeleteCommand = "Delete from ilker_sevim_sepets where seperID="+ p;
    if (SqlDataSource4.Delete() > 0)
    {
        siparisleriGetir();
        SqlDataSource4.DataBind();
        // Button1_Click(null, null);

        urunFiyatHesapla();
    }
    else
    { 
    }
}

private void urunFiyatHesapla()
{
    int tmpToplamUrunFiyati =0, tmpUAdeti;
    int tmpTekUrunFiyati;
    TextBox t;
    int sayici=0;
    foreach ( GridViewRow item in GridView1.Rows)
    {
        t= (TextBox)item.FindControl("TextBox2");
        tmpUAdeti = Convert.ToInt32(t.Text);
        tmpTekUrunFiyati =Convert.ToInt32(item.Cells[3].Text);
        tmpToplamUrunFiyati += tmpTekUrunFiyati * tmpUAdeti;
    }

    Label2.Text = tmpToplamUrunFiyati.ToString();
}

当我在按钮单击事件中调用 urunFiyatHesapla(); 方法时,它可以工作。当我将它绑定到 GridView 时,我得到一个错误。

我的错误在哪里?

【问题讨论】:

  • 好的,谢谢我解决了我的问题

标签: c# asp.net gridview


【解决方案1】:

你需要像这样绑定你的gridview GridView1.DataBind();

【讨论】:

    猜你喜欢
    • 2018-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-05
    • 1970-01-01
    • 1970-01-01
    • 2013-01-16
    • 2020-07-30
    相关资源
    最近更新 更多